title: asp.net repeater merge columns dynamically
body: <p>I have a repeater in my ASP.net page. I want to merge the columns which have same text. This should happen dynamically when I bind a datatable. I have searched a lot for this. But, without success. I doubt whether it is possible with a repeater. I would also like to mention that there are also image buttons and check boxes in each row.</p>
  
  <p>This is my repeater source:-</p>
  
  <pre><code>&lt;asp:Repeater ID="rpt1" runat="server" onitemcommand="rpt1_ItemCommand"&gt;
          &lt;HeaderTemplate&gt;
              &lt;table border="1" cellpadding="10" width="50%"&gt;
              &lt;tr&gt;
                  &lt;th&gt;Item Name&lt;/th&gt;
                  &lt;th&gt;As On&lt;/th&gt;
                  &lt;th&gt;Price&lt;/th&gt;
                  &lt;th&gt;&lt;/th&gt;
                  &lt;th&gt;&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/HeaderTemplate&gt;
          &lt;ItemTemplate&gt;
  
              &lt;tr&gt;
                  &lt;td&gt;
                      &lt;asp:Label ID="lblRelayName" runat="server" Text='&lt;%# Eval("ItemName") %&gt;'&gt;&lt;/asp:Label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:Label ID="lblTimeFrom" runat="server" Text='&lt;%# Eval("Date") %&gt;'&gt;&lt;/asp:Label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:Label ID="lblPrice" runat="server" Text='&lt;%# Eval("Price") %&gt;'&gt;&lt;/asp:Label&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:ImageButton ID="imgBtnStatus" runat="server" 
                          ImageUrl="~/img/btnGet.jpg" 
                          CommandName="Change"  style="width: 36px; border-width: 0px; margin-top: -4px; vertical-align: middle;" /&gt;
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;asp:CheckBox ID="chkStatus" runat="server" Checked="true" /&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
  
          &lt;/ItemTemplate&gt;
          &lt;FooterTemplate&gt;
              &lt;/table&gt;
          &lt;/FooterTemplate&gt;
  
          &lt;/asp:Repeater&gt;
  </code></pre>
  
  <p>This is how I fill the repeater:-</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      rpt1.DataSource = GetData();
      rpt1.DataBind();
  }
  
  private DataTable GetData()
  {
      DataTable dt = new DataTable();
      dt.Columns.Add("ItemName");
      dt.Columns.Add("Date");
      dt.Columns.Add("Price");
  
      DataRow dr = dt.NewRow();
      dr["ItemName"] = "Orange";
      dr["Date"] = "01/01/2015";
      dr["Price"] = "50";
      dt.Rows.Add(dr);
  
      dr = dt.NewRow();
      dr["ItemName"] = "Orange";
      dr["Date"] = "02/01/2015";
      dr["Price"] = "51";
      dt.Rows.Add(dr);
  
      dr = dt.NewRow();
      dr["ItemName"] = "Orange";
      dr["Date"] = "03/01/2015";
      dr["Price"] = "55";
      dt.Rows.Add(dr);
  
      dr = dt.NewRow();
      dr["ItemName"] = "Apple";
      dr["Date"] = "01/01/2015";
      dr["Price"] = "95";
      dt.Rows.Add(dr);
  
      dr = dt.NewRow();
      dr["ItemName"] = "Apple";
      dr["Date"] = "03/01/2015";
      dr["Price"] = "98";
      dt.Rows.Add(dr);
  
      dr = dt.NewRow();
      dr["ItemName"] = "Banana";
      dr["Date"] = "01/01/2015";
      dr["Price"] = "48";
      dt.Rows.Add(dr);
  
      return dt;
  }
  </code></pre>