Help getting values out of a repeater

Discussion in '.NET' started by Gengen, Jul 6, 2007.

  1. Gengen

    Gengen

    Joined:
    Jul 6, 2007
    Messages:
    2
    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!
    Gengen, Jul 6, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mrwoopey
    Replies:
    0
    Views:
    677
    mrwoopey
    Apr 15, 2004
  2. =?Utf-8?B?Y2hhcmxpZXdlc3Q=?=

    Getting data out of the Repeater Web Control

    =?Utf-8?B?Y2hhcmxpZXdlc3Q=?=, Jul 6, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    4,159
    =?Utf-8?B?SmVyZW15?=
    Jun 8, 2006
  3. jim.long@vanderbilt.edu

    Getting Value out of a data repeater checkbox

    jim.long@vanderbilt.edu, Dec 15, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    24,471
    jim.long@vanderbilt.edu
    Dec 15, 2005
  4. renil
    Replies:
    3
    Views:
    13,904
    Alan Silver
    Feb 6, 2006
  5. Baohua Li

    How to Get values out from repeater

    Baohua Li, Nov 25, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    112
    Baohua Li
    Nov 25, 2003
Loading...

Share This Page