ASP.net 做个考试系统,单选题用gridview链接数据库,将四个选项用四个radiobutton控件显示,然后后台代码
然后后台代码如下但是str的值一直是空的intscore=0;intsinglemark=10;//取出单选题的每题分值foreach(GridViewRowdrinGr...
然后后台代码如下 但是str的值一直是空的
int score = 0;
int singlemark = 10;//取出单选题的每题分值
foreach (GridViewRow dr in GridView2.Rows)//对单选题每题进行判断用户选择答案
{
string str = "";
if (((RadioButton)dr.FindControl("RadioButton1")).Checked)
{
str = "A";
}
else if (((RadioButton)dr.FindControl("RadioButton2")).Checked)
{
str = "B";
}
else if (((RadioButton)dr.FindControl("RadioButton3")).Checked)
{
str = "C";
}
else if (((RadioButton)dr.FindControl("RadioButton4")).Checked)
{
str = "D";
}
if (((Label)dr.FindControl("Label3")).Text == str)
{
score = score + singlemark;
}
}
Label31.Text = "分数是" + score.ToString(); 展开
int score = 0;
int singlemark = 10;//取出单选题的每题分值
foreach (GridViewRow dr in GridView2.Rows)//对单选题每题进行判断用户选择答案
{
string str = "";
if (((RadioButton)dr.FindControl("RadioButton1")).Checked)
{
str = "A";
}
else if (((RadioButton)dr.FindControl("RadioButton2")).Checked)
{
str = "B";
}
else if (((RadioButton)dr.FindControl("RadioButton3")).Checked)
{
str = "C";
}
else if (((RadioButton)dr.FindControl("RadioButton4")).Checked)
{
str = "D";
}
if (((Label)dr.FindControl("Label3")).Text == str)
{
score = score + singlemark;
}
}
Label31.Text = "分数是" + score.ToString(); 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询