简体   繁体   中英

How can I find out the selected value of Radio Button List in Repeater

aspx file:

I'm doing exams program. I view the answers in Radio Button List on Repeater . How can I find out the selected value of Radio Button List

<asp:Repeater ID="Rep_CatQuestion" runat="server" OnItemDataBound="Rep_CatQuestion_ItemDataBound">
                            <ItemTemplate>
                                <asp:HiddenField ID="CatQuID" runat="server" Value='<%# Eval("CatQuestionID") %>' />
                                <asp:HiddenField ID="HFCount" runat="server" Value='<%# Eval("CatQuestionCount") %>' />

                                <asp:Repeater ID="Rep_Question" runat="server" OnItemDataBound="Rep_Question_ItemDataBound">
                                    <ItemTemplate>
                                        <asp:HiddenField ID="QuID" runat="server" Value='<%# Eval("QuestionID") %>' />
                                        <div class="row rowPadding">
                                            <div class="col-md-12">
                                                <div class="col-md-8">
                                                    <h6>
                                                        <%# Eval("QuestionText")%></h6>
                                                </div>

                                            </div>
                                            <div class="col-md-12">
                                                <fieldset>
                                                    <div class="row">
                                                        <div class="col-md-6">
                                                                    <div class="form-group">
                                                        <asp:RadioButtonList  ID="Rep_Answer" runat="server" DataTextField="AnswerText" DataValueField="AnswerID" >

                                                        </asp:RadioButtonList>

                                                        </div></div>
                                                    </div>
                                                </fieldset>
                                            </div>
                                        </div>
                                    </ItemTemplate>
                                </asp:Repeater>

                            </ItemTemplate>
                        </asp:Repeater>

I want to get the selected value from RadioButtonList.

You have to loop through repeater and find each RadioButtonList as

foreach (RepeaterItem item in Rep_CatQuestion.Items)
{
    string value = (item.FindControl("Rep_Answer") as RadioButtonList).SelectedValue;
    ...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM