title: nested gridview get parent row
body: <p>I am using Nested GridViews where each row in the <em>gridview</em> has child gridView.
  I am using <strong>RowDataBound</strong> Event of <em>Parent GridView</em>, to Binding <em>Child GridView</em>.
  My Problem is that, how to get Parent GridView's Key on Child gridViews <strong>RowDataBound</strong> Event.</p>
  
  <p>Below is example code:</p>
  
  <pre><code>&lt;asp:GridView ID="gvParent" DataKeyNames="ID" runat="server" PageSize="1" AllowPaging="true" PagerSettings-Mode="NextPrevious" AutoGenerateColumns="False" SkinID="GVCenter" onrowdatabound="gvParent_RowDataBound"&gt;
     &lt;Columns&gt;
          &lt;asp:BoundField DataField="Name" /&gt;
          &lt;asp:TemplateField&gt;
             &lt;ItemTemplate&gt;
                 &lt;asp:GridView ID="gvChild"  DataKeyNames="ID" runat="server" AutoGenerateColumns="false" ShowHeader="false" OnRowDataBound="gvChild_RowDataBound"&gt;
                    &lt;Columns&gt;
                       &lt;asp:BoundField DataField="Name" /&gt;                     
                    &lt;/Columns&gt;
                  &lt;/asp:GridView&gt;
             &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
     &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Here is the code behind:</p>
  
  <pre><code>    protected void gvParent_RowDataBound(object sender, GridViewRowEventArgs e)
      {
          if (e.Row.RowType == DataControlRowType.DataRow)
          {
              GridView gvChild= (GridView)e.Row.FindControl("gvChild");
              gvChild.DataSource = getChildObj();
              gvChild.DataBind();
          }
      }
  
     protected void gvChild_RowDataBound(object sender, GridViewRowEventArgs e)
      {
          if (e.Row.RowType == DataControlRowType.DataRow)
          {
              // Here I need to get the parent gridview Row Key
          }
      }
  </code></pre>
  
  <p>Hope the above code explains all the scenario.</p>
  
  <p>Thanks in advance
  Sandy </p>