Organizational Research By

Surprising Reserch Topic

how to add a requiredfieldvalidator to dropdownlist control


how to add a requiredfieldvalidator to dropdownlist control  using -'asp.net,validation,drop-down-menu,requiredfieldvalidator'

I took the DropDownList and I binded the control using SqlDataSource to display the values from the database.

When I am validating using RequiredFieldValidator I am unable to make it work.
    

asked Sep 22, 2015 by kinnari
0 votes
20 views



Related Hot Questions

2 Answers

0 votes

For the most part you treat it as if you are validating any other kind of control but use the InitialValue property of the required field validator.


Basically what it's saying is that validation will succeed if any other value than the 1 set in InitialValue is selected in the dropdownlist.

If databinding you will need to insert the "Please select" value afterwards as follows

this.ddl1.Items.Insert(0, "Please select");
answered Sep 22, 2015 by akhilesh
0 votes

Suppose your Drop down list is:



....

You have two ways:

the 2nd way is to use a compare validator:

answered Sep 22, 2015 by sachin valanju

...