title: Radgrid Open/Expand child DetailGridView in insert mode from parent row command button
body: <p>I am using the Telerik RadGrid to display and edit Hierarchical data. As strange as this may sound - one of the requirements is to have a child detail grid open in insert mode when a link in the parent row is clicked. This requires two things. The expansion of the child grid, and getting this grid loaded in insert mode. </p>
  
  <p>This is what I've tried so far using the recommendations from Telerik documentation; However this doesn't work and throws an exception when rebind is called saying that the child detail grid can't find its linqDataSourceControl; however this control does exist while this code below is executing (I checked).</p>
  
  <p>What is the solution to open a child DetailGridView in insert mode from parent row command button?</p>
  
  <p>Markup:</p>
  
  <pre><code>...
      &lt;DetailTables&gt;
          &lt;telerik:GridTableView&gt;
          ...
          &lt;Columns&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:LinkButton ID="addChildVendorRating" runat="server" CommandName="AddNewChildRating" CausesValidation="false" CssClass="normal-link" CommandArgument='&lt;%# Eval("VendorM2MEntityToQualID")%&gt;'&gt;[Add Rating]&lt;/asp:LinkButton&gt;
              &lt;/ItemTemplate&gt;
          &lt;/Columns&gt;
          &lt;DetailTables&gt;
              &lt;!-- I Need this to be be expanded and in insert mode when addChildVendorRating command link is clicked --&gt;
              &lt;telerik:GridTableView&gt;
          &lt;/&lt;DetailTables&gt;
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>protected void gridRatings_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
  {
      if (e.CommandName == "AddNewChildRating") {
                  GridDataItem parentRow = e.Item as GridDataItem;
                  GridTableView parentGridView = parentRow.GetClosestParentControlByType&lt;GridTableView&gt;();
                  RadGrid parentGrid = parentGridView.GetClosestParentControlByType&lt;RadGrid&gt;();
  
                  parentRow.Expanded = true;
                  //parentGridView.HierarchyDefaultExpanded = true;
                  //parentGridView.DetailTables[0].InsertItem();
                  parentGridView.DetailTables[0].IsItemInserted = true;
                  parentGridView.DetailTables[0].Rebind();
      }
  }
  </code></pre>