Hi,
you can use RequiredFieldValidator for it, just set the InitialValue
property to the value of the first item in the DDL (the invalid one) and it
will then ensure that correct selection is made.
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"Ric Castagna" <> wrote in message
news: om...
> Hello, all...
>
> I'm trying to do a client-side validation on a databound dropdown
> list.
>
> All I want to do is check to see if the selected index is greater than
> 0 - an invalid option.
>
> Here's the code I'm using, but I don't think the compare validator is
> the right validation method to use. It, unfortunately, always thinks
> there's an error.
>
> <asp:dropdownlist id="ddlCategories" cssclass="adminText"
> datatextfield="cat_desc" datavaluefield="cat_id" runat="server" />
> <asp:comparevalidator id="cvCategories" operator="LessThan"
> controltovalidate="ddlCategories" valuetocompare="1"
> errormessage="Please select a category for this clip."
> display="Dynamic" runat="server" />
>
> I can't seem to find any postings on using validation against dropdown
> lists on the client side, and I'd prefer to keep the validation there
> as sending it server-side would really junk up the works.
>
> Please help.
>
> Thanks!
|