【问题标题】:Looping thru all radiobuttonlists on page循环遍历页面上的所有单选按钮列表
【发布时间】:2013-08-02 04:48:50
【问题描述】:

我有一个由主题内问题的嵌套重复对象组成的调查。一切都是通过数据库动态填充的。每个问题都有一个单选按钮列表的答案。每个主题可以有一个或多个问题。当用户完成表单并点击提交时,我的点击函数如何遍历所有控件,找到每个单选按钮列表及其选择的答案?

<div id="qDiv" runat="server" >
                <asp:Repeater runat="server" ID="rptSubject" OnItemDataBound="rptSubject_ItemDataBound">
                    <ItemTemplate>
                        <h2><%#DataBinder.Eval(Container.DataItem, "Subject")%></h2>
                        <asp:Repeater runat="server" ID="rptQuestion" OnItemDataBound="rptQuestion_ItemDataBound">
                            <ItemTemplate>
                                <p><%# DataBinder.Eval(Container.DataItem, "Question")%></p>

                                <asp:RadioButtonList ID="rblAnswers" runat="server"></asp:RadioButtonList>
                            </ItemTemplate>
                        </asp:Repeater>
                    </ItemTemplate>
                </asp:Repeater>
    </div>




protected void submitButton_Click(object sender, EventArgs e)
{
???
}

除了选择的答案,我还可以在点击功能中访问重复值问题和主题吗?

【问题讨论】:

    标签: c# .net radiobuttonlist nested-repeater


    【解决方案1】:

    使用Page.FindControl(string) 方法根据已知的 ID 模式查找服务器控件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-09
      • 2013-09-12
      • 2011-08-05
      • 2012-05-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多