title: How to get the value of a textbox on RadGrid ItemCommand event handler when using a Custom Command?
body: <p>I'm using RadGrid Form Templates as below;</p>
  
  <pre><code>&lt;EditFormSettings EditFormType="Template"&gt;
      &lt;FormTemplate&gt;
          &lt;table id="tblEditForm" cellpadding="2" cellspacing="2" width="100%" border="2px"
              class="tblEditForm"&gt;                           
              &lt;tr&gt;
                  &lt;th&gt;
                      Server Name:
                  &lt;/th&gt;
                  &lt;td&gt;
                      &lt;asp:TextBox ID="tbServerName" runat="server" Text='&lt;%# Bind("ServerName") %&gt;' CssClass="tbServerName"&gt;
                      &lt;/asp:TextBox&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;                                        
              &lt;tr&gt;
                  &lt;td colspan="2"&gt;
                      &lt;div style="text-align: left; padding-left: 10px;display: inline; width: 50%"&gt;
  
                          &lt;asp:LinkButton ID="lbTestConnection" runat="server" Text="Test Connection" CommandName="TestConnection" /&gt;
                          (It may take up to 15 seconds.)
                          &lt;br /&gt;                                                                         
                      &lt;/div&gt;
                      &lt;asp:Label ID="lblTestConnectionResult" runat="server" CssClass="testConnectionResult"&gt;&lt;/asp:Label&gt;      
                      &lt;div style="text-align: right; padding-right: 10px;display: inline; float: right;"&gt;
                          &lt;asp:Button ID="btnUpdate" Text='&lt;%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %&gt;'
                              runat="server" CommandName='&lt;%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %&gt;'&gt;
                          &lt;/asp:Button&gt;&amp;nbsp;
                          &lt;asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                              CommandName="Cancel"&gt;&lt;/asp:Button&gt;
                      &lt;/div&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/FormTemplate&gt;
  &lt;/EditFormSettings&gt;
  </code></pre>
  
  <p>When the Update link button is clicked on my RadGrid, the Edit Form is displayed.
  Then I click the Test Connection link button and ItemCommand event is raised.</p>
  
  <pre><code>public void OnRadGridItemCommand(object sender, GridCommandEventArgs e)
  {
      if (e.CommandName == "TestConnection")
      {               
          var gridEditFormItem = e.Item as GridEditFormItem;
          if (gridEditFormItem == null)
              throw new ApplicationException("gridEditFormItem is null");
          var serverNameTextBox = gridEditFormItem.FindControl("tbServerName") as TextBox;
      }
  }
  </code></pre>
  
  <p>The problem is that the gridEditFormItem variable is null at this stage so I can't figure out the value of the server name text box for example.</p>
  
  <p>How to get the value of the textbox on RadGrid ItemCommand event handler?</p>
  
  <p>If I click the default insert link button of the RadGrid instead, the gridEditFormItem has value so I can simply find the value of my textbox there.</p>
  
  <p>Please help.</p>
  
  <p>Thanks,</p>