Session 跨页面传数组
Page A:
ArrayList lit = new ArrayList();
ArrayList lit2 = new ArrayList();
Session["lit"] = lit;
Session["lit2"] = lit2;
Response.Redirect("Page B");
Page B:
DataTable dt = new DataTable(); //新建填充DataTable
dt.Columns.Add("id");
dt.Columns.Add("name");
ArrayList lit = (ArrayList)Session["lit"];
ArrayList lit2 = (ArrayList)Session["lit2"];
if(lit !=null && lit2!=null)
{
for (int i = 0; i < lit.Count;i++ )
{
DataRow dr;
dr=dt.NewRow();
dr["id"] = lit[i].ToString();
dr["name"] = lit2[i].ToString();
dt.Rows.Add(dr);
}
}