[英]radio button in repeater?
我已经设置了一个转发器,可以为每个问题重复一个单选按钮,每个问题中只需要一个单选按钮,这是我的代码,我怎样才能使单选按钮控件组?
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound" OnItemCommand="Repeater1_ItemCommand">
<ItemTemplate>
<div class="text-left" >
<strong>
<div>
<strong>
<li>
<div id="outer" style="background-color: lightblue"> <%# Eval("QuetionText")%></div>
<br />
</li>
<div>
<asp:Repeater ID="Repeater2" runat="server">
<ItemTemplate>
<li>
<div >
<asp:RadioButton ID="RadioButton1" runat="server" Text ='<%# Eval("ExamQuestionAnswerText")%>' ></asp:RadioButton>
<%--<asp:CheckBox ID="CheckBox1" runat="server" Text= '<%# Eval("ExamQuestionAnswerText")%>' />--%>
</div>
</li>
</ItemTemplate>
<FooterTemplate >
</FooterTemplate>
</asp:Repeater>
</div>
</strong>
</div>
</strong>
</div>
</ItemTemplate>
</asp:Repeater>
您可以通过绑定其属性GroupName来在子中继器中对单选按钮进行分组,如下所示:
<asp:RadioButton ID="RadioButton1" runat="server" Text ='<%# Eval("ExamQuestionAnswerText")%>'
GroupName='<%# Eval("QuestionId")%>'></asp:RadioButton>
您需要将QuestionId用作子转发器的dataSource。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.