aspx文件:
我正在做考试计划。我在Repeater的单选按钮列表中查看答案。如何找到单选按钮列表的选定值
<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>
我想从RadioButtonList中获取所选值。
答案 0 :(得分:0)
你必须遍历转发器并找到每个RadioButtonList为
foreach (RepeaterItem item in Rep_CatQuestion.Items)
{
string value = (item.FindControl("Rep_Answer") as RadioButtonList).SelectedValue;
...
}