protected void Button2_Click(object sender,EventArgs e) {
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/09/20 17:44:13
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;
}
}
}
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;
}
}
}
是 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
再问: HiddenField hf1 = (HiddenField)rw.FindControl("trueanwser"); HiddenField hf2 = (HiddenField)rw.FindControl("mark"); RadioButton rb1 = (RadioButton)rw.FindControl("RadioButton6"); 学生愚笨,求先生教这三句话啥意思, 我在网上查了他们说是强制转换成控件,我还是不明白,希望你可以讲给我听谢谢!
再答: 他的表格里,放了 3个控件,你可以看看他的 表格的代码 .net 的话 就是那一堆html 的代码里有 他里面定义了 trueanwser 和 mark 这2个 隐藏组件,用于放一些 不在界面上显示的内容 然后,他在还表格里定义了 RadioButton 控件,用于你在界面上 勾选的那个 小框框 每次循环的行的时候,就把这3个取出来,因为你使用rw.FindControl 这个方法取的,得到的只是 control 所以,要强制转换成你需要的
判断 表格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
再问: HiddenField hf1 = (HiddenField)rw.FindControl("trueanwser"); HiddenField hf2 = (HiddenField)rw.FindControl("mark"); RadioButton rb1 = (RadioButton)rw.FindControl("RadioButton6"); 学生愚笨,求先生教这三句话啥意思, 我在网上查了他们说是强制转换成控件,我还是不明白,希望你可以讲给我听谢谢!
再答: 他的表格里,放了 3个控件,你可以看看他的 表格的代码 .net 的话 就是那一堆html 的代码里有 他里面定义了 trueanwser 和 mark 这2个 隐藏组件,用于放一些 不在界面上显示的内容 然后,他在还表格里定义了 RadioButton 控件,用于你在界面上 勾选的那个 小框框 每次循环的行的时候,就把这3个取出来,因为你使用rw.FindControl 这个方法取的,得到的只是 control 所以,要强制转换成你需要的
protected void Button2_Click(object sender,EventArgs e) {
protected void Button1_Click(object sender,EventArgs e
private void button16_Click(object sender,EventArgs e)
英语翻译private void button1_Click(object sender,EventArgs e){if
VC++中object sender的用法
帮忙理解事件托管其中的object sender(事件发行者) 与keyEventArges e 的实际意义,与其作用
protected void onCreate(Bundle icicle) { if (DBG) log("onCre
HTML部分代码:游>RadioButtonList事件:protected void rdoMode_T_Select
英语翻译An error has been signaled by the Protected Object Serve
object
英语翻译Three types of patent can be protected in P.R.China,i.e.
sender reimbursement thru