写了一个 问题调查 想让答案显示在gridview ,于是我将Cookie制作出来了,
下面就是我写的 有些粗糙,   下面的问题是 如何让值读取到  GridView1.Rows[sz].Cells[1].Text  中。
我用c#写的 数据库是ACCESS asp.net2008    比较急 在线等····大家帮忙救火啊 ··· int[] aq = new int[10];
       for (int sz = 1; sz <=5; sz++)
       {
           if (Label2.Text == sz.ToString())
           {
               HttpCookie cookie = new HttpCookie(aq[sz].ToString());               if (RadioButton1.Checked == true) { cookie.Value = "A"; }
               if (RadioButton2.Checked == true) { cookie.Value = "B"; }
               if (RadioButton3.Checked == true) { cookie.Value = "C"; }
               if (RadioButton4.Checked == true) { cookie.Value = "D"; }
               if (RadioButton5.Checked == true) { cookie.Value = "E"; }
               cookie.Expires = DateTime.Now.AddMinutes(20);
               Response.Cookies.Add(cookie);

解决方案 »

  1.   

    在RowDataBound 中写查找到那列的 TextBox, 然后给它设值就好了
      

  2.   

    这个 跟  GridView1.Rows[sz].Cells[1].Text   意思是一样的 ··
    谁能告诉我 如何用 数组做 COOKIE  
    如果成功的话 那应该可以解决 这个问题了····
     HttpCookie cookie[sz] = new HttpCookie(aq[sz].ToString());但是这样写 系统又识别不了···报错··无效的表达项“=”跟 “;”  这个部分[sz] = 标注起来....
      

  3.   

    你在外面放一个数组啊,把数组放到cookie里
      

  4.   

    失败 ···识别不了 ··能给个COOKIE数组的例子吗
      

  5.   

     HttpCookie [] cookies = new HttpCookie[5]; 干嘛不这样声明一个数组啊
      

  6.   

    radio是不是固定有几个啊,Gridview的行数也固定吗
      

  7.   

    radio就5个··不用 数组是无法改变的····
      

  8.   

    求一个 COOKIE 的 数组 例子!!!最好是关于 赋值的那种····
      

  9.   

    现在还有一个问题是 值是读取出来了··可是为什么每次读取的时候 都是 同一个答案呢··
    答案的内容  ID=1时: 选了A  然后 ID=2时 选了B
    检查的时候就会变成   ID1=B ; ID2=B
    正确的应该是:ID1=A; ID2=B  (要的这个效果没有实现,向求教···)HttpCookieCollection cookies;
           cookies = Request.Cookies;
           string[] num = new string[5]; 
         
           
           //for (int i = 1; i < num; i++)
           for (int i = 1; i <= num.Length; i++)
           { 
     HttpCookie abc = new HttpCookie("num"+i.ToString ());
               DateTime dt = DateTime.Now;
           TimeSpan ts = new TimeSpan(0, 0, 1, 0, 0); //过期时间为1分钟
           abc.Expires = dt.Add(ts);
     if (RadioButton1.Checked == true) 
    { abc.Values.Add("num" + i.ToString(), "A"); }
               if (RadioButton2.Checked == true) 
    { abc.Values.Add("num" + i.ToString(), "B"); }
               if (RadioButton3.Checked == true)
     { abc.Values.Add("num" + i.ToString(), "C"); }
               if (RadioButton4.Checked == true) 
    { abc.Values.Add("num" + i.ToString(), "D"); }
               if (RadioButton5.Checked == true)
     { abc.Values.Add("num" + i.ToString(), "E"); }
    Response.Cookies.Add(abc); HttpCookie ba = Request.Cookies["num" + i.ToString()];
    }
     for (int a = 1; a <= Convert.ToInt32(Label2.Text); a++)
           {
               Response.Write(Request.Cookies["num"+a.ToString()].Value);
           }