button点击事件后arraylist的值就永不了,大家帮忙看看为什么,求助

coolnameismy1 2012-04-07 06:07:30
protected void Button1_Click(object sender, EventArgs e) //查询按钮
{
bindselect();
for (int i = 0; i < GridView1.Rows.Count; i++)
{

pass[i] = GridView1.Rows[i].Cells[1].Text.ToString();
string str = pass[i];
ListBox1.Items.Add(str);
alist.Add(str);
}

ListBox2.DataSource = alist;
ListBox2.DataBind();

bindselect()为gridview1绑定数据,这时候可以看到listbox2显示正常,就是alist数据正常。然后用passdata()进行数组页面传递,alist就没有数据了,值传不过去。接受页面不会有问题,因为我把 Session["shuzu"] = alist;这句话放在上一段的最末尾就可以顺利传过去,那我觉得可能就是离开按钮事件后alist的值就取不到了,这个是为什么。程序写的有点罗嗦,因为方便我查看一些字段的数值是否正确。

public void passdata()
{
Session["shuzu"] = alist;
string strURL = "WebForm3.aspx?shuzu=" + alist;
HttpContext.Current.Response.Redirect(strURL);

}
...全文
44 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧