0

I have a survey composed of nested repeater objects of questions that are within subjects. Everything is populated dynamically via the database. Each question has a radiobuttonlist of answers. There can be one or many questions per subject. When the user complete the form and click submit, how does my click function loop through all controls, find each radiobuttonlist and its' selected answer?

<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)
{
???
}

As well as the selected answer, can I also get access to the repeaters values question & subject in the click function?

Csharp
  • 2,916
  • 16
  • 50
  • 77
NikZ
  • 650
  • 3
  • 8
  • 20

1 Answers1

0

Use the Page.FindControl(string) method to find server controls based on a known ID pattern.

Cam Bruce
  • 5,632
  • 19
  • 34