title: RequiredFieldValidator for a dropdownlist
body: <p>I have a dropdownlist which I am developing dynamically in the code.</p>
  
  <pre><code>  Dim objPreferenceDropdownList As DropDownList = New DropDownList()
                          objPreferenceDropdownList.ID = "objPreferenceDropdownList"
                          objPreferenceDropdownList.AppendDataBoundItems = "True"
  
                objPreferenceDropdownList.AutoPostBack = True
  </code></pre>
  
  <p>I am populating this dropdown with different items such as </p>
  
  <pre><code>objPreferenceDropdownList.Items.Add(new ListItem("--Select Color--","0"));
  
   objPreferenceDropdownList.Items.Add(new ListItem("Red","1"));
  
   objPreferenceDropdownList.Items.Add(new ListItem("Blue","2"));
  
  objPreferenceDropdownList.Items.Add(new ListItem("White", "3"));
  
  objPreferenceDropdownList.Items.Add(new ListItem("Pink", "4"));
  </code></pre>
  
  <p>Now I need to validate the dropdownlist it there is no any item selected in the dropdown for that I created a required field validator dynamically like this:</p>
  
  <pre><code>Dim reqPrefGroupValidator As RequiredFieldValidator = New RequiredFieldValidator()
                                  reqPrefGroupValidator.ControlToValidate = "objPreferenceDropdownList"
                                  reqPrefGroupValidator.InitialValue = "0"
                                  reqPrefGroupValidator.SetFocusOnError = True
                                  prefdiv.Controls.Add(reqPrefGroupValidator)
  </code></pre>
  
  <p>The problem is required field validator only works when dropdownlist is empty what if I need to fire requiredfieldvalidator when the selected item value of dropdownlist is zero.</p>