Validate Nested RadioButtonList

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.
 
V

vinu

HI,

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

protected System.Web.UI.WebControl.RadioButtonList RblCities

Vinu
 
G

Guest

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

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

Top