具体实现如下
if (mandName == "delete")//判断操作
{int index1 = Convert.ToInt32(mandArgument); string del =
this.GridView1.Rows[index1].Cells[0].Text.ToString();
myconn.Open();
SqlCommand cmd = new SqlCommand("select 使用 from
T_SingleChoice where 题目ID='" + del + "' ", myconn);
SqlDataReader dr = cmd.ExecuteReader(); int i = 0;
while (dr.Read()) if (i < GridView1.Rows.Count && dr[0].ToString() == "1") {
Response.Redirect("ManageSingleChoice.aspx"); }i++; dr.Close();
string del1 = "delete from T_SingleChoice where 题目ID='" + del + "'";//删除字符串
SqlCommand del2 = new SqlCommand(del1, myconn); GridView1dataBind();//数据再次绑定 shuaxin();//页面刷新 刷新页面的函数
protected void shuaxin() {
SqlCommand cmd = new SqlCommand("select 使用,题干 from T_SingleChoice where 科目ID='" + DropDownList1.SelectedValue + "'", Con1); SqlDataReader dr = cmd.ExecuteReader(); CheckBox checkbox1;
while (dr.Read()){
if (i < GridView1.Rows.Count && dr[0].ToString() == "1"){ checkbox1 =(CheckBox)GridView1.Rows[i].
FindControl("CheckBox1");checkbox1.Checked = true;} i++;}
}
4 添加题目
题目的添加必须要完整,否则就不能做为一道题目来使用,即作为单选题,所有选项和题干都不能为空,正确答案和难度系数也不能为空。一旦题目不完整,
就不能添加。如下所示:
信息填写完整后,添加成功结果如下
实现过程如下
protected void Button1_Click(object sender, EventArgs e) {
string answer=null;string level = null; for(int i=1;i<=3;i++){