Validate Nested RadioButtonList

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have the following nested RadioButtonList in my web page that displays a
list of cities (categorized in states) for the user to select. There's a
RequiredFieldValidator to ensure user has selected one state.

<asp:RequiredFieldValidator ID="VrqCity" runat="server" CssClass="error"
ErrorMessage="Please select a city" ControlToValidate="RblCities" /><br />

<asp:Repeater ID="RptStates" runat="server"
OnItemDataBound="GetBackPageTemplates">
<ItemTemplate>

<strong><%# DataBinder.Eval(Container.DataItem,
"stateName").ToString()%></strong>
<hr />

<asp:RadioButtonList ID="RblCities" runat="server"
RepeatDirection="Horizontal" RepeatColumns="5" CssClass="text"
CellPadding="5" />

</ItemTemplate>
</asp:Repeater>

However, when the page is loaded, it shows the error:

Unable to find control id 'RblCities' referenced by the 'ControlToValidate'
property of 'VrqCity'.

What's wrong?


ywb.
 
HI,

In the code behind page check RadioButtonList is declared or not. Your code
should have

protected System.Web.UI.WebControl.RadioButtonList RblCities

Vinu
 
The declaration is done by VS2005 in the partial class, and I can access
it's selectedValue etc in the code-behind.
 
Back
Top