There is a situation in drop down list where first item is "[Select]" and you need to make mandatory selection from drop down list except "[Select]".
Means, user must select value from drop down list but did not allow to select first element "[Select]". We can achieve this using required field validator control. For that we need to set "InitialValue" property.
Here is example for this.
In this example we take one product drop down list control in this list we list out all products, But the First Item is "[Select]" and it's value is "-1" in product drop downlist.
And We take one Required Field Validator control and set it's ValidateControl property to product drop down list id. We also set "InitialValue=-1" property.
We also took one button so that on click of button required field valdator control validate user input.
In this example we set InitialValue to -1 so that , if user select "[Select]" item from drop down list and click on "Save" button Validator control executed and validation message display on screen.
You can see that validation message in output.
Means, user must select value from drop down list but did not allow to select first element "[Select]". We can achieve this using required field validator control. For that we need to set "InitialValue" property.
Here is example for this.
In this example we take one product drop down list control in this list we list out all products, But the First Item is "[Select]" and it's value is "-1" in product drop downlist.
And We take one Required Field Validator control and set it's ValidateControl property to product drop down list id. We also set "InitialValue=-1" property.
We also took one button so that on click of button required field valdator control validate user input.
In this example we set InitialValue to -1 so that , if user select "[Select]" item from drop down list and click on "Save" button Validator control executed and validation message display on screen.
You can see that validation message in output.