Help getting values out of a repeater

Joined
Jul 6, 2007
Messages
2
Reaction score
0
I have a radiobuttonlist I'm repeating and I need to know if I can get the values they select (1-10 for a survey)? Using c# looks like this:

Code:
    protected void submit_Click(object sender, EventArgs e)
    {
        foreach (RepeaterItem riRating in this.Questions.Items)
        {
            RadioButtonList rating = (RadioButtonList)riRating.FindControl("rbList");
            Label1.Text += rating.SelectedIndex.ToString() + "</br>";
        }
        
    }

ASP:

Code:
 <asp:Repeater ID ="Questions" runat="server">
            <ItemTemplate>
                <table>
                    <tr style ="border-bottom-color:black">
                        <td colspan="3" style="height: 20px">
                            <asp:Label ID="Label1" runat="server"></asp:Label>
                            <b><%# DataBinder.Eval(Container.DataItem, "Question")%>
                               </b>
                            </td>
                    </tr>
                    <tr>
                        <td style="width: 63px; height: 20px">
                            Not Good</td>
                        <td style="width: 22px; height: 20px">
                            <asp:RadioButtonList ID="rbList" runat="server" AutoPostBack="False" BorderStyle="none"
                                Height="34px" 
                                RepeatDirection="Horizontal" Width="44px ">
                                <asp:ListItem Value="1"></asp:ListItem>
                                <asp:ListItem Value="2"></asp:ListItem>
                                <asp:ListItem Value="3"></asp:ListItem>
                                <asp:ListItem Value="4"></asp:ListItem>
                                <asp:ListItem Value="5"></asp:ListItem>
                                <asp:ListItem Value="6"></asp:ListItem>
                                <asp:ListItem Value="7"></asp:ListItem>
                                <asp:ListItem Value="8"></asp:ListItem>
                                <asp:ListItem Value="9"></asp:ListItem>
                                <asp:ListItem Value="10"></asp:ListItem>
                            </asp:RadioButtonList></td>
                        <td style="width: 45px; height: 20px">
                            Excellent</td><br />
                        <td style="width: 45px; height: 20px"><br />
                        <asp:Label ID="lblAnswer" runat="server" Visible="true" Text=""></asp:Label></td>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:Repeater>
    &nbsp;<asp:Button ID="submit" Text="Submit" runat="server" OnClick="submit_Click"/>
    <br />
    <asp:Label ID="Label1" runat="server"></asp:Label>


rbList is the ID for the actual radiobuttonlist and not the repeater. Any ideas? Help would be greatly appreciated or other ideas of how to do this!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top