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>

解决方案 »

  1.   

    获取每个radiobutton的值一起去跟数据库中的进行比较嘛
    http://www.lokcore.com/avrilxu/article.asp?id=5
      

  2.   

    楼主你的这些RadionButton应该有同样的GroupName才对吧?在提交按钮中如何实现判断每题所点的radiobutton是否与标准答案一致 
    ==
    一个一个和数据库的数据比对
      

  3.   

    关键是repeater会产生很多题,如何去取这一个一个的题目
    怎么控制循环
      

  4.   

    <asp:Label ID="Label1" runat="server" Text='<%#Eval("")%>' /> 
                  <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去判断了
      

  5.   

    protected void ReadRepeaterItems()
            {
                foreach (RepeaterItem RItem in Repeater1.Items)
                {
                    for (int i = 0; i < RItem.Controls.Count; i++)
                    {
                        if (RItem.Controls[i].GetType().ToString() == "RadioButtonList")
                        {
                            //todo:
                            break;
                        }
                    }
                }
            }
    这样的话,比较麻烦
      

  6.   

    一般应该用RadioButtonList 而不是RadioButton
      

  7.   

    你也可以用脚本去得到radiobuttonlist集合,然后去遍厉
    window.document.getElementsByTagName(TagName);去获取,你可以查一下文档,看一下这个TagName是什么东西
      

  8.   

    用Hidden保存正确答案,可以在客户端用JS判断题目是否正确,但是答案会泄露。在服务器端判断时,
    在每一行中,保存题目的序号(主键)
    提交时,同时取得每行的题目序号,去匹配答案。
      

  9.   

    如何将数据库中不同字段加到每个listitem中去
    我用<asp:ListItem Text=' <%#Eval("subject")%>' Value=""> </asp:ListItem>
        <asp:ListItem Text="1" Value=""> ' <%#Eval("subject")%>'</asp:ListItem>
    系统均报错
    该如何解决,谢谢