C# 存取Session值
//存入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();
}声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇:没有了
- 下一篇:没有了
