//存入Session
protected void Button1_Click(object sender, EventArgs e)
{
string[] str = new string[] { "A", "B", "C", "D" };
Session["str"] = str;
Session["ds"] =Class1.ExecuteDataset("Data Source=.;Initial Catalog=northwnd;User ID=sa;Password=123", "select * from product", CommandType.Text, null);
}
//获取Session
protected void Button2_Click(object sender, EventArgs e)
{
object o = Session["str"];
string[] str =(string[])o;
foreach (string item in str)
{
Response.Write(item + "<br>");
}
GridView1.DataSource = (DataSet)Session["ds"];
GridView1.DataBind();
}
C# 存取Session值
最新推荐文章于 2023-07-26 16:49:44 发布