日期:2014-05-18 浏览次数:20542 次
SqlDataReader sdr = cmd.ExecuteReader(); while (sdr.Read()) { Literal littxt = new Literal(); Literal litti = new Literal(); //CheckBoxList che = new CheckBoxList();//复选框多选择 CheckBoxList cbk = new CheckBoxList(); littxt.Text = "<input type='hidden' name='db_" + bie.ToString() + "' id='db_" + bie + "' value='' answer='" + Server.HtmlEncode(sdr["rightAns"].ToString()) + "'/>" + "<div class='result' id='result_" + bie.ToString() + "' >" + i.ToString() + "、" + Server.HtmlEncode(sdr["testContent"].ToString()); litti.Text = "</div>"; littcookie["littxt"] += HttpUtility.UrlEncode(littxt.Text + "|"); littcookie["acbk"] += HttpUtility.UrlEncode(sdr["testAns1"].ToString()) + "|"; littcookie["bcbk"] += HttpUtility.UrlEncode(sdr["testAns2"].ToString()) + "|"; littcookie["ccbk"] += HttpUtility.UrlEncode(sdr["testAns3"].ToString()) + "|"; littcookie["dcbk"] += HttpUtility.UrlEncode(sdr["testAns4"].ToString()) + "|"; cbk.Items.Add("A. " + Server.HtmlEncode(sdr["testAns1"].ToString())); cbk.Items.Add("B. " + Server.HtmlEncode(sdr["testAns2"].ToString())); cbk.Items.Add("C. " + Server.HtmlEncode(sdr["testAns3"].ToString())); cbk.Items.Add("D. " + Server.HtmlEncode(sdr["testAns4"].ToString())); cbk.Font.Size = 11; for (int j = 1; j <= 4; j++) { cbk.Items[j - 1].Attributes.Add("onclick", " db(" + bie.ToString() + ", " + num++ + ")");//给input标签加事件 } num = 1; bie++; Ans += sdr[6].ToString(); if (Session["a"] == null) { Session["Ans"] = Ans; } cbk.Attributes.Remove("name"); Panel1.Controls.Add(littxt); Panel1.Controls.Add(cbk); Panel1.Controls.Add(litti); i++; tNUM++; }