title: Bind Nested Gridview with Radiobuttonlist
body: <p>I have a nested <code>Gridiew</code>. The parent shows <code>customers</code> and the child shows each part for that <code>customer</code>.</p>
  
  <p>For information :<br />
  <strong><code>grdViewCustomers</code> shows the <code>customers</code>.<br />
  <code>grdviewordersofcustomer</code> shows the parts for each <code>customer</code>.</strong></p>
  
  <p>In the <code>ChildGridview</code> I have a <code>RadioButtonList</code> so you can select what part type it is.</p>
  
  <p>I have the <code>ChildGridview</code> and Parent databind using <code>grdviewcustomers_onrowdatabound</code> in <code>.cs</code>.</p>
  
  <p>I can get value from <code>RadioButtonList</code>. However I can not pull data from SQL and set to appropriate value on page load. Could anyone assist? I feel close but no gold yet.</p>
  
  <pre><code>protected void grdViewCustomers_OnRowDataBound(object sender, GridViewRowEventArgs e)
  {
      if (e.Row.RowType == DataControlRowType.DataRow)
      {
          string customerID = grdViewCustomers.DataKeys[e.Row.RowIndex].Value.ToString();
          GridView grdViewOrdersOfCustomer = (GridView)e.Row.FindControl("grdViewOrdersOfCustomer");
          grdViewOrdersOfCustomer.DataSource = SelectData("select * from [dbo].[View_Budget_Setup_2_Items] WHERE CUSID='" + customerID + "' order by id_item");
          grdViewOrdersOfCustomer.DataBind();
  
          foreach (GridViewRow rowChild in grdViewOrdersOfCustomer.Rows)
          {
              string ChildID = grdViewOrdersOfCustomer.DataKeys[rowChild.RowIndex].Value.ToString();
              string Editable = dbUtilities.SalesEditableID(ChildID);
  
              if (Editable == "Bud")
              {
                // Set values here
  
              }
          }
  
  
          grdViewOrdersOfCustomer.DataBind();
          //testing
      }
  }
  </code></pre>
  
  <p>ASPX side</p>
  
  <pre><code>&lt;div&gt;
      &lt;asp:GridView ID="grdViewCustomers" runat="server" AutoGenerateColumns="false" DataKeyNames="ID"
           CssClass="Grid" EmptyDataText="No Budgets To Approve" OnRowDataBound="grdViewCustomers_OnRowDataBound"&gt;
          &lt;Columns&gt;
              &lt;asp:TemplateField ItemStyle-Width="20px"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;a href="JavaScript:divexpandcollapse('div&lt;%# Eval("ID") %&gt;');"&gt;
                          &lt;img alt="Details" id='imgdiv&lt;%# Eval("ID") %&gt;' src="images/plus.png" /&gt;
                      &lt;/a&gt;
                      &lt;div id='div&lt;%# Eval("ID") %&gt;' style="display: none;"&gt;
                          &lt;asp:GridView ID="grdViewOrdersOfCustomer" runat="server" AutoGenerateColumns="false"
                              DataKeyNames="ID" CssClass="ChildGrid" OnRowDataBound="grdViewOrdersOfCustomer_RowDataBound"&gt;
                              &lt;Columns&gt;
                                  &lt;asp:BoundField ItemStyle-Width="150px" DataField="ID" HeaderText="ID" Visible="False" /&gt;
                                  &lt;asp:BoundField ItemStyle-Width="150px" DataField="ID_CUST_SOLDTO" HeaderText="Customer Name" /&gt;
                                  &lt;asp:BoundField ItemStyle-Width="100px" DataField="id_item" HeaderText="Item" /&gt;
                                  &lt;asp:BoundField ItemStyle-Width="75px" DataField="PN5YB" HeaderText="-5 Back" /&gt;
                                  &lt;asp:BoundField ItemStyle-Width="75px" DataField="PN4YB" HeaderText="-4 Back" /&gt;
                                  &lt;asp:BoundField ItemStyle-Width="75px" DataField="PN3YB" HeaderText="-3 Back" /&gt;
                                  &lt;asp:BoundField ItemStyle-Width="75px" DataField="PN2YB" HeaderText="-2 Back" /&gt;
                                  &lt;asp:BoundField ItemStyle-Width="75px" DataField="PN1YB" HeaderText="-1 Back" /&gt;
                                  &lt;asp:BoundField ItemStyle-Width="75px" DataField="PN0YB" HeaderText="This Year" /&gt;
                                  &lt;asp:BoundField ItemStyle-Width="75px" DataField="Area" HeaderText="Area" /&gt;
                                  &lt;asp:TemplateField HeaderText="Edit"&gt;
                                      &lt;ItemTemplate&gt;
                                          &lt;asp:RadioButtonList ID="RadioCusListC" runat="server" RepeatDirection="Horizontal"&gt;
                                              &lt;asp:ListItem Text="Bud" /&gt;
                                              &lt;asp:ListItem Text="B/O" /&gt;
                                              &lt;asp:ListItem Text="B/G" /&gt;
                                              &lt;asp:ListItem Text="DNB" /&gt;
                                          &lt;/asp:RadioButtonList&gt;
                                      &lt;/ItemTemplate&gt;
                                  &lt;/asp:TemplateField&gt; 
                              &lt;/Columns&gt;
                          &lt;/asp:GridView&gt;
                      &lt;/div&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:BoundField DataField="ID_CUST_SOLDTO" SortExpression="ID_CUST_SOLDTO" ItemStyle-Width="90px" /&gt;
                  &lt;asp:BoundField DataField="PN5YB" SortExpression="PN5YB" DataFormatString="{0:C0}" ItemStyle-Width="90px" ItemStyle-HorizontalAlign="Right" /&gt;
                  &lt;asp:BoundField DataField="PN4YB" SortExpression="PN4YB" DataFormatString="{0:C0}" ItemStyle-Width="90px" ItemStyle-HorizontalAlign="Right" /&gt;
                  &lt;asp:BoundField DataField="PN3YB" SortExpression="PN3YB" DataFormatString="{0:C0}" ItemStyle-Width="90px" ItemStyle-HorizontalAlign="Right" /&gt;
                  &lt;asp:BoundField DataField="PN2YB" SortExpression="PN2YB" DataFormatString="{0:C0}" ItemStyle-Width="90px" ItemStyle-HorizontalAlign="Right" /&gt;
                  &lt;asp:BoundField DataField="PN1YB" SortExpression="PN1YB" DataFormatString="{0:C0}" ItemStyle-Width="90px" ItemStyle-HorizontalAlign="Right" /&gt;
                  &lt;asp:BoundField DataField="PN0YB" SortExpression="PN0YB" DataFormatString="{0:C0}" ItemStyle-Width="90px" ItemStyle-HorizontalAlign="Right" /&gt;
                  &lt;asp:BoundField DataField="area" SortExpression="Area" ItemStyle-Width="90px" ItemStyle-HorizontalAlign="Right" /&gt;
              &lt;asp:TemplateField HeaderText="Edit"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:RadioButtonList ID="RadioCusList"  runat="server" RepeatDirection="Horizontal"&gt;
                          &lt;asp:ListItem Text="Bud" /&gt;
                          &lt;asp:ListItem Text="B/O" /&gt;
                          &lt;asp:ListItem Text="B/G" /&gt;
                          &lt;asp:ListItem Text="DNB" /&gt;
                          &lt;asp:ListItem Text="Err" /&gt;
                  &lt;/asp:RadioButtonList&gt;
                  &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
          &lt;/Columns&gt;
      &lt;/asp:GridView&gt;
  
     &lt;/div&gt;
  </code></pre>