写在页面的另一个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;