中继器中的单选按钮?

时间:2014-12-01 12:32:19

标签: c# asp.net 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>

1 个答案:

答案 0 :(得分:0)

您可以通过将其属性GroupName绑定在子转发器中来对您的单选按钮进行分组,如:

  <asp:RadioButton ID="RadioButton1" runat="server"  Text ='<%# Eval("ExamQuestionAnswerText")%>'  
GroupName='<%# Eval("QuestionId")%>'></asp:RadioButton>

您需要为子转发器的dataSource带来QuestionId。