repeater控件中有若干项,其中有四项前面都带radiobutton作单项选择
这样就产生若干个选择题
最后有个提交按钮
在提交按钮中如何实现判断每题所点的radiobutton是否与标准答案一致
望指教,谢谢repeater代码如下:
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("subject") %>' />
<p>
<asp:RadioButton ID="RadioButton1" runat="server" value='<%# Eval("choice1") %>' />
<asp:Label ID="Label11" runat="server" Text= 'A. ' />
<asp:Label ID="Label12" runat="server" Text= '<%# Eval("choice1") %>' />
<p>
<asp:RadioButton ID="RadioButton2" runat="server" value='<%# Eval("choice2") %>' />
<asp:Label ID="Label21" runat="server" Text= 'B. ' />
<asp:Label ID="Label22" runat="server" Text='<%# Eval("choice2") %>' />
<p>
<asp:RadioButton ID="RadioButton3" runat="server" value='<%# Eval("choice3") %>' />
<asp:Label ID="Label31" runat="server" Text= 'C. ' />
<asp:Label ID="Label32" runat="server" Text='<%# Eval("choice3") %>' />
<p>
<asp:RadioButton ID="RadioButton4" runat="server" value='<%# Eval("choice4") %>' />
<asp:Label ID="Label41" runat="server" Text= 'D. ' />
<asp:Label ID="Label42" runat="server" Text='<%# Eval("choice4") %>' />
<p>
</ItemTemplate>
</asp:Repeater>
这样就产生若干个选择题
最后有个提交按钮
在提交按钮中如何实现判断每题所点的radiobutton是否与标准答案一致
望指教,谢谢repeater代码如下:
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("subject") %>' />
<p>
<asp:RadioButton ID="RadioButton1" runat="server" value='<%# Eval("choice1") %>' />
<asp:Label ID="Label11" runat="server" Text= 'A. ' />
<asp:Label ID="Label12" runat="server" Text= '<%# Eval("choice1") %>' />
<p>
<asp:RadioButton ID="RadioButton2" runat="server" value='<%# Eval("choice2") %>' />
<asp:Label ID="Label21" runat="server" Text= 'B. ' />
<asp:Label ID="Label22" runat="server" Text='<%# Eval("choice2") %>' />
<p>
<asp:RadioButton ID="RadioButton3" runat="server" value='<%# Eval("choice3") %>' />
<asp:Label ID="Label31" runat="server" Text= 'C. ' />
<asp:Label ID="Label32" runat="server" Text='<%# Eval("choice3") %>' />
<p>
<asp:RadioButton ID="RadioButton4" runat="server" value='<%# Eval("choice4") %>' />
<asp:Label ID="Label41" runat="server" Text= 'D. ' />
<asp:Label ID="Label42" runat="server" Text='<%# Eval("choice4") %>' />
<p>
</ItemTemplate>
</asp:Repeater>
http://www.lokcore.com/avrilxu/article.asp?id=5
==
一个一个和数据库的数据比对
怎么控制循环
<p>
<asp:RadioButtonList ID="fdfdsf" runat="server" RepeatDirection="vertical">
<asp:ListItem Text="1" Value=""></asp:ListItem>
<asp:ListItem Text="2" Value=""></asp:ListItem>
<asp:ListItem Text="3" Value=""></asp:ListItem>
<asp:ListItem Text="4" Value=""></asp:ListItem>
<asp:ListItem Text="5" Value=""></asp:ListItem>
</asp:RadioButtonList>
<加入一个hidden> 保存正确答案
<p>
</ItemTemplate> 然后就是取Repeater的各个item去判断了
{
foreach (RepeaterItem RItem in Repeater1.Items)
{
for (int i = 0; i < RItem.Controls.Count; i++)
{
if (RItem.Controls[i].GetType().ToString() == "RadioButtonList")
{
//todo:
break;
}
}
}
}
这样的话,比较麻烦
window.document.getElementsByTagName(TagName);去获取,你可以查一下文档,看一下这个TagName是什么东西
在每一行中,保存题目的序号(主键)
提交时,同时取得每行的题目序号,去匹配答案。
我用<asp:ListItem Text=' <%#Eval("subject")%>' Value=""> </asp:ListItem>
<asp:ListItem Text="1" Value=""> ' <%#Eval("subject")%>'</asp:ListItem>
系统均报错
该如何解决,谢谢