Answer 6
The best and low cost way will be doing it ion your sql query.
but you can do this by adding Template column in GridView and add 3 lables in it, that will be bound to Col1, Col2 and Col3. or Fetch the data from database as
SELECT Name,Col1 + ',' + Col2 + ',' + Col2 As Code From Table and use this Code column to bind with gridviews' column.
or
To merge column header in a gridview you can use OnRowCreated Event of Grid View.
if (e.Row.RowType == DataControlRowType.Header)
{
//Build own custom header.
GridView oGridView = (GridView)sender;
GridViewRow oGridViewRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
TableCell oTableCell = new TableCell();
//Add Department
oTableCell.Text = "Department";
oTableCell.ColumnSpan = 2;
oGridViewRow.Cells.Add(oTableCell);
//Add Employee
oTableCell = new TableCell();
oTableCell.Text = "Employee";
oTableCell.ColumnSpan = 3;
oGridViewRow.Cells.Add(oTableCell);
oGridView.Controls[0].Controls.AddAt(0, oGridViewRow);
}