写了一个 问题调查 想让答案显示在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);
下面就是我写的 有些粗糙, 下面的问题是 如何让值读取到 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);
谁能告诉我 如何用 数组做 COOKIE
如果成功的话 那应该可以解决 这个问题了····
HttpCookie cookie[sz] = new HttpCookie(aq[sz].ToString());但是这样写 系统又识别不了···报错··无效的表达项“=”跟 “;” 这个部分[sz] = 标注起来....
答案的内容 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);
}