title: ASP.NET - Get control in RowCommand event
body: <p>Trying to access a RequiredFieldValidator control that's inside a GridView in the RowCommand event and having trouble.</p>
  
  <p>Here's the partial GridView code:</p>
  
  <pre><code>&lt;asp:TemplateField HeaderText="Password"&gt;
      &lt;ItemTemplate&gt;
          &lt;asp:TextBox ID="txtPassword" runat="server" CssClass="GridViewTextbox" TextMode="Password" Text='&lt;%#Eval("WebPassword") %&gt;' Enabled="false"&gt;&lt;/asp:TextBox&gt;
      &lt;/ItemTemplate&gt;
      &lt;EditItemTemplate&gt;
          &lt;asp:TextBox ID="txtWebPassword" runat="server" TextMode="Password" Text='&lt;%#Eval("WebPassword") %&gt;'&gt;&lt;/asp:TextBox&gt;
          &lt;asp:RequiredFieldValidator ID="rfvPassword" runat="server" SetFocusOnError="true"
              ControlToValidate="txtWebPassword" Display="None" ErrorMessage='&lt;%# Constants.Strings.PasswordRequired %&gt;'&gt;&lt;/asp:RequiredFieldValidator&gt;
      &lt;/EditItemTemplate&gt;
      &lt;FooterTemplate&gt;
          &lt;asp:TextBox ID="txtAddWebPassword" runat="server" TextMode="Password"&gt;&lt;/asp:TextBox&gt;
          &lt;asp:RequiredFieldValidator ID="rfvAddPassword" runat="server" SetFocusOnError="true"
              ControlToValidate="txtAddWebPassword" Display="None" ErrorMessage='&lt;%# Constants.Strings.PasswordRequired %&gt;'&gt;&lt;/asp:RequiredFieldValidator&gt;
      &lt;/FooterTemplate&gt;
  &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>As you can see, there's a RFV for the EditTemplate and FooterTemplate.  My issue is this; when the page loads, it has all the records in it, including an emtpy row at the bottom (Footer).  If I click Edit on a populated row, the data is populated correctly, then when I hit UPDATE, I get all the error messages from the FOOTER RFV's firing off, which isn't correct.  So, in the RowCommand event, I'd like to attempt this:  If the user clicks the EDIT button, then disable all the RFV's in the footer row (the add new row), if they click anything else, enable them.</p>
  
  <p>Ideas?</p>
  
  <p>Sorry, meant to put this in the first time.  In the RowCommand event, I am able to find the control but when I set the properties to something bogus, it seems to get overridden later, by the RowDataBound event:</p>
  
  <pre><code>            RequiredFieldValidator rfv = (RequiredFieldValidator)gvUsers.FooterRow.FindControl("rfvAddWebLogin");
              rfv.ControlToValidate = string.Empty;
              rfv.ErrorMessage = "sdfgsdfgsdgsdfgsdfgsdfgsdfg";
              rfv.Enabled = false;
  </code></pre>