Validation for Dropdown list
-
I am using a 'Required Field Validator' for my Dropdown list but it doesn't work , if I do not select any thing from the list it still saves the form and I guess that is necause it assmues the first entry in the list as selected always no matter what the first item is. I also tried using 'Range Validator' to see that the item selected from the dropdown is between 2 & 10... item no 1 in the dropdown is 'Please Select' , but that is not working as well.. does anyone have an idea as to which validator will work to see that the user HAS selected an entry from the dropdown else the form will not save. Thank you for your precious time invested in answering this query. Aartee. ...HE is watching Us All!
-
I am using a 'Required Field Validator' for my Dropdown list but it doesn't work , if I do not select any thing from the list it still saves the form and I guess that is necause it assmues the first entry in the list as selected always no matter what the first item is. I also tried using 'Range Validator' to see that the item selected from the dropdown is between 2 & 10... item no 1 in the dropdown is 'Please Select' , but that is not working as well.. does anyone have an idea as to which validator will work to see that the user HAS selected an entry from the dropdown else the form will not save. Thank you for your precious time invested in answering this query. Aartee. ...HE is watching Us All!
use the custom validator - private void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args) { if ( !dropdown.SelectedIndex == 0 ) args.IsValid = false; }