title: insert new row with detailsview on gridview's EmptyDataTemplate
body: <p>I use the gridview to manage the data, when the database does not contain the data it needs to be input first. to input data the first time I use detailsview that I put in the gridview's EmptyDataTemplate.
  how to access detailview's textbox which is in gridview's EmptyDataTemplate?I always get error null reference</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;EmptyDataTemplate&gt;                
                  &lt;asp:DetailsView ID="DetailsView3" runat="server" AutoGenerateRows="False" DataKeyNames="IDKOREKSIREFUND" DataSourceID="KoreksiRefundObjectDataSource" DefaultMode="Insert" Height="50px" Width="125px" &gt;
                      &lt;Fields&gt;
                          &lt;asp:BoundField DataField="IDKOREKSIREFUND" HeaderText="IDKOREKSIREFUND" InsertVisible="False" ReadOnly="True" SortExpression="IDKOREKSIREFUND" /&gt;
                          
                          &lt;asp:TemplateField HeaderText="NILAI" SortExpression="NILAI"&gt;                            
                              &lt;InsertItemTemplate&gt;
                                  &lt;asp:TextBox ID="dvNilaiTextBox" runat="server" Text='&lt;%# Bind("NILAI") %&gt;'&gt;&lt;/asp:TextBox&gt;
                              &lt;/InsertItemTemplate&gt;                            
                          &lt;/asp:TemplateField&gt;
                          
                          &lt;asp:CommandField ShowInsertButton="True" /&gt;
                      &lt;/Fields&gt;
                  &lt;/asp:DetailsView&gt;
              &lt;/EmptyDataTemplate&gt;
          &lt;/asp:GridView&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <pre><code>protected void KoreksiRefundObjectDataSource_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
      {
          if (KoreksiGridView.Rows.Count == 0)
          // We are inserting through the DetailsView in the EmptyDataTemplate
          {                
              TextBox NewNilai1 = (TextBox)KoreksiGridView.FooterRow.Controls[0].FindControl("dvNilaiTextBox");
  
              decimal? NILAI1 = null;
              if (!string.IsNullOrEmpty(NewNilai1.Text))
                  NILAI1 = Convert.ToDecimal(NewNilai1.Text);
              e.InputParameters["NILAI"] = NewNilai1.Text;
  
              return;
          }
  
  
          // Programmatically reference Web controls in the inserting interface...
          TextBox NewNilai= (TextBox)KoreksiGridView.FooterRow.FindControl("NewNilaiTextBox");                    
  
          decimal? NILAI = null;
          if (!string.IsNullOrEmpty(NewNilai.Text))
              NILAI = Convert.ToDecimal(NewNilai.Text);
          e.InputParameters["NILAI"] = NewNilai.Text;
  
      }
  </code></pre>