Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Databound Dropdown List and validation

Reply
Thread Tools

Databound Dropdown List and validation

 
 
Ric Castagna
Guest
Posts: n/a
 
      01-15-2004
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!
 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      01-16-2004
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!



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
databound custom controls vs composite databound custom controls rodchar ASP .Net 0 11-26-2007 03:51 PM
Make a value the default in a databound dropdown Steve ASP .Net 3 09-14-2006 01:55 AM
Multiple databound dropdown lists Lair ASP .Net 2 06-21-2006 06:38 PM
templated databound control problem - not showing databound Manu ASP .Net Web Controls 0 05-22-2006 09:46 AM
Adding a "Select" option to a databound dropdown Simon Harvey ASP .Net 2 01-18-2006 12:54 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57