写在页面的另一个Button的Click事件里,试了很久,终于解决了,谢谢大家:
代码改为下面的:
String strTitle, strNum;
Hashtable hash=new Hashtable(50);
int iNum=GridView1.Rows.Count;
for (int i = 0; i < iNum; i++)
{ CheckBox check = (CheckBox)GridView1.Rows[i].Cells[0].Controls[1]; if (check.Checked)
{
TextBox textQuantity = (TextBox)GridView1.Rows[i].Cells[2].Controls[1];
strTitle = GridView1.Rows[i].Cells[1].Text; strNum = textQuantity.Text;
hash.Add(strTitle, strNum);
}
}
Session["basket"] = hash;
代码改为下面的:
String strTitle, strNum;
Hashtable hash=new Hashtable(50);
int iNum=GridView1.Rows.Count;
for (int i = 0; i < iNum; i++)
{ CheckBox check = (CheckBox)GridView1.Rows[i].Cells[0].Controls[1]; if (check.Checked)
{
TextBox textQuantity = (TextBox)GridView1.Rows[i].Cells[2].Controls[1];
strTitle = GridView1.Rows[i].Cells[1].Text; strNum = textQuantity.Text;
hash.Add(strTitle, strNum);
}
}
Session["basket"] = hash;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货