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:
ASP:
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!
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>
<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!