title: Dropdownlist validation in Asp.net Using Required field validator
body: <p>I have Dropdownlist whose value field and text field are bind at runtime.
  it has <code>--select--</code> as first item with a value of <code>0</code>
  and the rest of the values are bind at runtime.</p>
  
  <p>I have given validaton group for both the control and the validator as <code>"g1"</code>
  and <code>Intialvalue=0</code></p>
  
  <p>But still the page is posting  back even if I select <code>--select--</code> option.</p>
  
  <pre><code>&lt;asp:DropDownList AutoPostBack="true" CssClass="dropdown" ValidationGroup="g1" 
      ID="ddlReportType" runat="server" 
      OnSelectedIndexChanged="ddlReportType_SelectedIndexChanged"&gt;&lt;/asp:DropDownList&gt;
  
  &lt;asp:RequiredFieldValidator ControlToValidate="ddlReportType" ID="RequiredFieldValidator1"
  ValidationGroup="g1" CssClass="errormesg" ErrorMessage="Please select a type"
  InitialValue="0" runat="server"  Display="Dynamic"&gt;
  &lt;/asp:RequiredFieldValidator&gt;
  </code></pre>
  
  <p>And code Behind to Bind the Dropdown </p>
  
  <pre><code>ddlReportType.Items.Clear();
  ddlReportType.DataSource = dt.Tables[0];
  ddlReportType.DataTextField = "ReportType";
  ddlReportType.DataValueField = "ReportTypeID";
  ddlReportType.DataBind();
  ddlReportType.Items.Insert(0, new ListItem("--Select--", "0"));
  //ddlReportType.Items[0].Value = "0";
  ddlReportType.SelectedIndex = 0;
  </code></pre>