string sql = "select answer from tb_schoose ";
SqlDataAdapter dataAdapter=new SqlDataAdapter(sql,conn);
DataSet dataset=new DataSet();
dataAdapter.Fill(dataset,"tb_schoose");
DataTable datatable = dataset.Tables["tb_schoose"];
int c = 0;//存答正确答案
for (int a = 0; a < GridView1.Rows.Count; a++)
{
RadioButtonList rbl = (RadioButtonList)(GridView1.Rows[a].FindControl("rbanswer"));//取用户所选答案
Label lblc = (Label)(GridView1.Rows[a].FindControl("lblc"));
if (rbl != null && rbl.SelectedValue != "")
{
string answer =datatable.Rows[a]["answer"].ToString().Trim();//取正确答案
if (rbl.SelectedValue.ToString().Trim() == answer)//比较
{
c = c + 1;
lblc.Text = "回答正确";
}
else
{
lblc.Text = "回答错";
}
}
}
btnjj.Enabled = false;//交完一次就不能在交
SqlDataAdapter dataAdapter=new SqlDataAdapter(sql,conn);
DataSet dataset=new DataSet();
dataAdapter.Fill(dataset,"tb_schoose");
DataTable datatable = dataset.Tables["tb_schoose"];
int c = 0;//存答正确答案
for (int a = 0; a < GridView1.Rows.Count; a++)
{
RadioButtonList rbl = (RadioButtonList)(GridView1.Rows[a].FindControl("rbanswer"));//取用户所选答案
Label lblc = (Label)(GridView1.Rows[a].FindControl("lblc"));
if (rbl != null && rbl.SelectedValue != "")
{
string answer =datatable.Rows[a]["answer"].ToString().Trim();//取正确答案
if (rbl.SelectedValue.ToString().Trim() == answer)//比较
{
c = c + 1;
lblc.Text = "回答正确";
}
else
{
lblc.Text = "回答错";
}
}
}
btnjj.Enabled = false;//交完一次就不能在交