title: Chrome browser - Colspan not working in GridView as expected using C# ASP.NET
body: <p>I'm trying to dynamically add row and add Columns with Colspan (<em>ColumnSpan</em>) to GridView in ASP.Net using C#.</p>
  <p>My problem is the <code>Colspan attribute</code> works fine in <code>Internet Explorer</code> browser, however, in <code>Chrome</code> browser, all the content which is supposed to be spread over the columns, only goes into the 1st column.</p>
  <p>This is the output in Chrome browser</p>
  <p><a href="https://i.stack.imgur.com/OMfhR.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>Any ideas how to fix this?</p>
  <p><strong>GridView Markup</strong></p>
  <pre><code>&lt;asp:GridView ID=&quot;gvCustomers&quot; AutoGenerateColumns=&quot;false&quot; runat=&quot;server&quot; OnRowDataBound=&quot;gvProducts_RowDataBound&quot;&gt;
      &lt;Columns&gt;
          &lt;asp:BoundField DataField=&quot;CustomerId&quot; HeaderText=&quot;N.&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;CompanyName&quot; HeaderText=&quot;CompanyName&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;ContactName&quot; HeaderText=&quot;ContactName&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;ContactTitle&quot; HeaderText=&quot;ContactTitlle&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;Address&quot; HeaderText=&quot;Address&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;Region&quot; HeaderText=&quot;Region&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;City&quot; HeaderText=&quot;City&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;PostalCode&quot; HeaderText=&quot;PostalCode&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;Country&quot; HeaderText=&quot;Country&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;Phone&quot; HeaderText=&quot;Phone&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;Fax&quot; HeaderText=&quot;Fax&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;CustomerId&quot; HeaderText=&quot;CustomerId&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;CompanyName&quot; HeaderText=&quot;CompanyName&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;ContactName&quot; HeaderText=&quot;ContactName&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;ContactTitle&quot; HeaderText=&quot;ContactTitlle&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;Address&quot; HeaderText=&quot;Address&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;Region&quot; HeaderText=&quot;Region&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;City&quot; HeaderText=&quot;City&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;PostalCode&quot; HeaderText=&quot;PostalCode&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;Country&quot; HeaderText=&quot;Country&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;Phone&quot; HeaderText=&quot;Phone&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;Fax&quot; HeaderText=&quot;Fax&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;CustomerId&quot; HeaderText=&quot;CustomerId&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;CompanyName&quot; HeaderText=&quot;CompanyName&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;ContactName&quot; HeaderText=&quot;ContactName&quot; /&gt;
          &lt;asp:BoundField DataField=&quot;Fax&quot; HeaderText=&quot;Fax&quot; /&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  <p><strong>GridView .CS</strong></p>
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      if(!this.IsPostBack)
      {
          this.BindGrid();
      }
  }
   
  private void BindGrid()
  {
      string conString = ConfigurationManager.ConnectionStrings[&quot;constr&quot;].ConnectionString;
      using (SqlConnection con = new SqlConnection(conString))
      {
          using (SqlCommand cmd = new SqlCommand(&quot;SELECT * FROM Customers;&quot;, con))
          {
              using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
              {
                  using (DataTable dt = new DataTable())
                  {
                      sda.Fill(dt);
                      gvCustomers.DataSource = dt;
                      gvCustomers.DataBind();
                  }
              }
          }   
      }
  }
   
  protected void gvProducts_RowDataBound(object sender, GridViewRowEventArgs e)
  {
      if (e.Row.RowType == DataControlRowType.Header)
      {
          GridViewRow HeaderRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
   
          TableCell HeaderCell = new TableCell();
          HeaderCell.Text = &quot;&quot;;
          HeaderCell.ColumnSpan = 4;
          HeaderRow.Cells.Add(HeaderCell);
   
          HeaderCell = new TableCell();
          HeaderCell.Text = &quot;661&quot;;
          HeaderCell.ColumnSpan = 2;
          HeaderRow.Cells.Add(HeaderCell);
   
          TableCell HeaderCell1 = new TableCell();
          HeaderCell1 = new TableCell();
          HeaderCell1.Text = &quot;662&quot;;
          HeaderCell1.ColumnSpan = 2;
          HeaderRow.Cells.Add(HeaderCell1);
   
          TableCell HeaderCell2 = new TableCell();
          HeaderCell2 = new TableCell();
          HeaderCell2.Text = &quot;663&quot;;
          HeaderCell2.ColumnSpan = 2;
          HeaderRow.Cells.Add(HeaderCell2);
   
          TableCell HeaderCell3 = new TableCell();
          HeaderCell3 = new TableCell();
          HeaderCell3.Text = &quot;664&quot;;
          HeaderCell3.ColumnSpan = 2;
          HeaderRow.Cells.Add(HeaderCell3);
   
          TableCell HeaderCell4 = new TableCell();
          HeaderCell4 = new TableCell();
          HeaderCell4.Text = &quot;665&quot;;
          HeaderCell4.ColumnSpan = 2;
          HeaderRow.Cells.Add(HeaderCell4);
   
          TableCell HeaderCell5 = new TableCell();
          HeaderCell5 = new TableCell();
          HeaderCell5.Text = &quot;669&quot;;
          HeaderCell5.ColumnSpan = 2;
          HeaderRow.Cells.Add(HeaderCell5);
   
          TableCell HeaderCell6 = new TableCell();
          HeaderCell6 = new TableCell();
          HeaderCell6.Text = &quot;667&quot;;
          HeaderCell6.ColumnSpan = 2;
          HeaderRow.Cells.Add(HeaderCell6);
   
          TableCell HeaderCell7 = new TableCell();
          HeaderCell7.Text = &quot;THE OTHERS&quot;;
          HeaderCell7.ColumnSpan = 2;
          HeaderRow.Cells.Add(HeaderCell7);
   
          TableCell HeaderCell8 = new TableCell();
          HeaderCell8.Text = &quot;END&quot;;
          HeaderCell8.ColumnSpan = 2;
          HeaderRow.Cells.Add(HeaderCell8);
   
          TableCell HeaderCell9 = new TableCell();
          HeaderCell9.Text = &quot;&quot;;
          HeaderCell9.ColumnSpan = 2;
          HeaderRow.Cells.Add(HeaderCell9);
   
          HeaderRow.Attributes.Add(&quot;class&quot;, &quot;labelStyle&quot;);
          gvCustomers.Controls[0].Controls.AddAt(0, HeaderRow);
      }
  }
  </code></pre>