Dropdownlist and requiredfieldvalidator postback problem

  • Thread starter Thread starter anandv81
  • Start date Start date
A

anandv81

Hi,

I have a dropdownlist and a requiredfieldvalidator that checks if a
value has been selected for the dropdownlist by the user. I am
populating the ddl at runtime and adding two items ( "Please select"
and "All") the "Please select" option has a value of "".

The problem I am facing is that when I select the "Please select"
option the error message of the requiredfield validator gets displayed
for a second or so and then the page posts back. I wanted that the
error message should be displayed and the page shouldnt post back, am I
doing something wrong here?. I could check the value of the selected
item at the server side but thats just a waste of one round trip. The
autopostback property of the dropdownlist is set to true. Any help
would be appreciated . Thanks in advance.

Regards

Andy
 
Hi anand
Try setting "please select" item values to "-1" and in requiredfield
validator give initial value as -1.
Let me know if this doesn't solve.
 
Back
Top