title: Required Field Validator in Gridview depend on condition c#
body: <p>I have a required field validator in a Gridview. I want fire the validater only if the ddlPartsStatus is "Ordered". I just can't get it to work. </p>
  
  <p>At the moment required field validator fires for all the textboxes.</p>
  
  <p>my code</p>
  
  <pre><code>&lt;asp:GridView ID="gvPartsToOrderDetail" CssClass="gvPartsToOrderDetail" runat="server" AutoGenerateColumns="false" OnRowDataBound="gvPartsToOrderDetail_RowDataBound"&gt;
      &lt;Columns&gt;
          &lt;asp:TemplateField HeaderText="Ticket Number"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:TextBox ID="txtTicketNo" Text='&lt;%# Eval("TicketNo") %&gt;' runat="server"&gt;&lt;/asp:TextBox&gt;
                  &lt;asp:RequiredFieldValidator ID="rfvTxtTicketNo" runat="server" ForeColor="Red" Font-Bold="true" Font-Size="Medium" ErrorMessage="*" ControlToValidate="txtTicketNo" ValidationGroup="Submit"&gt;&lt;/asp:RequiredFieldValidator&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Parts Status"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:DropDownList ID="ddlPartStatus" runat="server" AutoPostBack="true"&gt;
                      &lt;asp:ListItem Value="0" Text="-Select-"&gt;&lt;/asp:ListItem&gt;
                      &lt;asp:ListItem Value="1" Text="Ordered"&gt;&lt;/asp:ListItem&gt;
                  &lt;/asp:DropDownList&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  
  &lt;asp:Button ID="btnSubmit" CssClass="btnSubmit" runat="server" Text="Submit" ValidationGroup="Submit" OnClick="btnSubmit_Click" /&gt;
  </code></pre>
  
  <p>Any help is greatly appreciated. Thanks</p>