Hi celv,
I have created one sample that full-fill your requirement.
HTML
<asp:GridView runat="server" ID="gvDetails" AutoGenerateColumns="false" OnRowCreated="gvDetails_RowCreated">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Mobile" HeaderText="Mobile" />
</Columns>
</asp:GridView>
Code
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)),
new DataColumn("Name", typeof(string)),
new DataColumn("Mobile",typeof(Int64)) });
dt.Rows.Add(1, "celv", 1111111111);
dt.Rows.Add(2, "ram", 2222222222);
dt.Rows.Add(2, "hari", 3333333333);
gvDetails.DataSource = dt;
gvDetails.DataBind();
}
}
protected void gvDetails_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
GridViewRow row = new GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Insert);
TableCell th = new TableHeaderCell();
th.ForeColor = Color.White;
th.BackColor = Color.SteelBlue;
th.Text = "Details of Employee";
th.ColumnSpan = gvDetails.Columns.Count;
row.Cells.Add(th);
gvDetails.Controls[0].Controls.AddAt(0, row);
}
}
Screenshot
