RadioButton rb = this.FindControl("RadioButton" + i) as RadioButton; if (rb.Checked) level = rb.Text;
for (int i = 6; i <= 9; i++){ RadioButton rb = this.FindControl("RadioButton" + i) as RadioButton; if (rb.Checked){
answer = rb.Text;}}
SqlConnection con ;con.Open();
string sql = " insert into T_SingleChoice(科目ID,题干,选项A,选项B,选项C,选项D,正确答案,试题难度系数) values('" +
DropDownList1.SelectedValue + "','" + TextBox2.Text + "','" +
TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text + "','" + answer + "','" + level + "');"; SqlCommand cm = new SqlCommand(sql, con); cm.ExecuteNonQuery(); con.Close();
Response.Redirect("ManageSingleChoice.aspx");
5.2.2 多选题管理
1.启用和作废
数据库中用0,1判断试题使用情况,为1时,可被抽选,抽选之后的题,不能被删除,为0时不能被抽选,为1时,Gridview中的checkbox自动选中,为0的不被选中。实现代码如下:if (i < GridView1.Rows.Count && dr[0].ToString() == "1")
checkbox1 = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1"); checkbox1.Checked = true;