protected void Button2_Click(object sender,EventArgs e) {int t = 0;foreach (GridViewRow rw in GridView1.Rows){HiddenField hf1 = (HiddenField)rw.FindControl("trueanwser"); string answer = hf1.Value; HiddenField hf2 = (HiddenField)rw.FindControl("mark"

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/06 02:35:44

protected void Button2_Click(object sender,EventArgs e) {int t = 0;foreach (GridViewRow rw in GridView1.Rows){HiddenField hf1 = (HiddenField)rw.FindControl("trueanwser"); string answer = hf1.Value; HiddenField hf2 = (HiddenField)rw.FindControl("mark"
protected void Button2_Click(object sender,EventArgs e) {
int t = 0;
foreach (GridViewRow rw in GridView1.Rows)
{
HiddenField hf1 = (HiddenField)rw.FindControl("trueanwser"); string answer = hf1.Value;
HiddenField hf2 = (HiddenField)rw.FindControl("mark");
int mark = Convert.ToInt32(hf2.Value);
RadioButton rb1 = (RadioButton)rw.FindControl("RadioButton6");
switch (answer)
{
case "answer1":
if (rb1.Checked)
{
t = t + mark;
}
break;
case "answer2":if (((RadioButton)rw.FindControl("RadioButton7")).Checked)
{
t = t + mark;
}
break;
case "answer3":
if (((RadioButton)rw.FindControl("RadioButton8")).Checked)
{
t = t + mark;
}
break;
case "answer4":
if (((RadioButton)rw.FindControl("RadioButton9")).Checked)
{
t = t + mark;
}
break;
case "answer5":
if (((RadioButton)rw.FindControl("RadioButton10")).Checked)
{
t = t + mark;
}
break;
default:
t = t + 0;
break;
}
}
}

protected void Button2_Click(object sender,EventArgs e) {int t = 0;foreach (GridViewRow rw in GridView1.Rows){HiddenField hf1 = (HiddenField)rw.FindControl("trueanwser"); string answer = hf1.Value; HiddenField hf2 = (HiddenField)rw.FindControl("mark"
是 c#的表格 ,当电击Button2 时候触发
判断 表格GridView1 的每一行
从每行 中 取出 trueanwser ,mark 和RadioButton
然后,根据 这3个组件的值去判断 switch
当 trueanwser 为 answer1 并且 RadioButton6选中 t +mark
当trueanwser 为 answer2并且 RadioButton7选中 t +mark
当trueanwser 为 answer3并且 RadioButton8选中 t +mark
当trueanwser 为 answer4并且 RadioButton9选中 t +mark
当trueanwser 为 answer5并且 RadioButton10选中 t +mark