title: Group one DataSet with Nested Repeater
body: <p>Suppose I have some book data like this:</p>
  
  <p><img src="https://i.stack.imgur.com/HKSzc.png" alt="enter image description here"></p>
  
  <p>And I have a query like <code>SELECT * FROM BookData</code> which outputs it in the above format.</p>
  
  <p>I would like to use nested repeater controls to output the data in an html <code>&lt;table&gt;</code> that will look something like this, with the data results grouped by Author:</p>
  
  <p><img src="https://i.stack.imgur.com/7NnQO.png" alt="enter image description here"></p>
  
  <p>So far I have my asp.net web form code looking like this:</p>
  
  <pre><code>&lt;table&gt;
      &lt;asp:Repeater ID="RepeaterInner" runat="server"&gt;
      &lt;ItemTemplate&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;asp:TextBox Text='&lt;%# Eval("Book") %&gt;' /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;asp:TextBox Text='&lt;%# Eval("Author") %&gt;' /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;asp:TextBox Text='&lt;%# Eval("PublishDate") %&gt;' /&gt;&lt;/td&gt; 
          &lt;td&gt;&lt;asp:TextBox Text='&lt;%# Eval("Pages") %&gt;' /&gt;&lt;/td&gt;         
      &lt;/tr&gt;
      &lt;/ItemTemplate&gt;
      &lt;/asp:Repeater&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>and my behind code this:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
          {          
  
              DataSet ds = GetData();
              RepeaterInner.DataSource = ds;
              RepeaterInner.DataBind();
  
          }
  
          private DataSet GetData() 
          {
              string CS = ConfigurationManager.ConnectionStrings["MyDB"].ConnectionString;
              using (SqlConnection con = new SqlConnection(CS))
              {
                  using (SqlCommand cmd = new SqlCommand("spGetData"))
                  {
                      cmd.CommandType = CommandType.StoredProcedure;
                      cmd.Connection = con;
                      con.Open();
                      SqlDataAdapter da = new SqlDataAdapter();
                      da.SelectCommand = cmd;
                      DataSet ds = new DataSet();
                      da.Fill(ds);
                      con.Close();
                      return ds;                   
                  }
              }
          }
  </code></pre>
  
  <p>For the final product I want it to look like this:</p>
  
  <pre><code>&lt;table&gt;
      &lt;asp:Repeater ID="RepeaterOuter" runat="server"&gt;
      &lt;ItemTemplate&gt;
          &lt;tr&gt;
          &lt;td&gt;&lt;asp:TextBox Text='&lt;%# Eval("Author") %&gt;' /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;asp:Repeater ID="RepeaterInner" runat="server"&gt;
          &lt;ItemTemplate&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;asp:TextBox Text='&lt;%# Eval("Book") %&gt;' /&gt;&lt;/td&gt;
              &lt;td&gt;&lt;asp:TextBox Text='&lt;%# Eval("PublishDate") %&gt;' /&gt;&lt;/td&gt; 
              &lt;td&gt;&lt;asp:TextBox Text='&lt;%# Eval("Pages") %&gt;' /&gt;&lt;/td&gt;         
          &lt;/tr&gt;
          &lt;/ItemTemplate&gt;
          &lt;/asp:Repeater&gt;    
      &lt;/ItemTemplate&gt;
      &lt;/asp:Repeater&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>But I am really confused on what to do to make the above happen. Can it be done with my one <code>DataSet</code> above generated from my one stored procedure? What do I need to do for each Repeater's <code>ItemDataBound</code> event handler if anything?</p>
  
  <p>Thank you.</p>