Hi akhter,
Check this example. Now please take its reference and correct your code.
HTML
<asp:GridView ID="GridView1" AutoGenerateSelectButton="false" AutoGenerateColumns="false" runat="server" Width="1432px"
OnDataBound="GridView1_DataBound">
<Columns>
<asp:ButtonField ButtonType="Link" CommandName="Select" ControlStyle-ForeColor="Red" HeaderText="Action" ItemStyle-Width="50"
Text="<i class='fa fa-pencil' aria-hidden='true'></i>" />
<asp:TemplateField HeaderText="Import No">
<ItemTemplate>
<asp:Label ID="IMp_ID" runat="server" ControlStyle-Width="50px" Enabled="true" Text='<%#Eval("IMp_ID") %>'></asp:Label>
<a href="impedit.aspx?ID=<%#Eval("IMp_ID") %>"><%# Eval("IMp_ID") %>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Suppplier_Asset" HeaderText="Supplier" Visible="True" />
<asp:BoundField DataField="Code" HeaderText="Code" Visible="True" />
<asp:BoundField DataField="Shipping_Line" HeaderText="Shipper" Visible="True" />
<asp:BoundField DataField="Imp_Date" HeaderText="Date" Visible="True" />
<asp:BoundField DataField="Inv_ID" HeaderText="Inv_ID" Visible="True" />
<asp:BoundField DataField="Value" HeaderText="Value" Visible="True" />
<asp:BoundField DataField="Inv_Weight" HeaderText="Weight" Visible="True" />
<asp:BoundField DataField="Bales" HeaderText="Bales" Visible="True" />
<asp:BoundField DataField="Inv_Currency" HeaderText="Currency" Visible="True" />
<asp:BoundField DataField="Inv_Date" HeaderText="Date" Visible="True" />
<asp:BoundField DataField="ID" HeaderText="ID" Visible="True" />
<asp:BoundField DataField="Forwarder" HeaderText="Forwarder" Visible="True" />
<asp:BoundField DataField="Forwarder_Currency" HeaderText="Currency" Visible="True" />
<asp:BoundField DataField="Foreign_Value" HeaderText="Value" Visible="True" />
<asp:BoundField DataField="Forwarder_Date" HeaderText="Date" Visible="True" />
</Columns>
</asp:GridView>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.Add("IMp_ID");
dt.Columns.Add("Suppplier_Asset");
dt.Columns.Add("Code");
dt.Columns.Add("Shipping_Line");
dt.Columns.Add("Imp_Date");
dt.Columns.Add("Inv_ID");
dt.Columns.Add("Value");
dt.Columns.Add("Inv_Weight");
dt.Columns.Add("Bales");
dt.Columns.Add("Inv_Currency");
dt.Columns.Add("Inv_Date");
dt.Columns.Add("ID");
dt.Columns.Add("Forwarder");
dt.Columns.Add("Forwarder_Currency");
dt.Columns.Add("Foreign_Value");
dt.Columns.Add("Forwarder_Date");
dt.Rows.Add(1, "Pakistan", "Has", "126000003", "14/05/2021", "ABC-22", "55.00", "545.00", "55", "200.00", "14/05/2021", "INV_003", "Ayhan Shipping", "45.00", "5.54", "14/05/2021");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
protected void GridView1_DataBound(object sender, EventArgs e)
{
GridViewRow row = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);
TableHeaderCell cell = new TableHeaderCell();
cell.Text = "Action";
cell.ColumnSpan = 1;
cell.Attributes.Add("style", "text-align:center !important;");
row.Controls.Add(cell);
cell = new TableHeaderCell();
cell.ColumnSpan = 5;
cell.Text = "Shipper Info";
cell.Attributes.Add("style", "text-align:center !important;");
row.Controls.Add(cell);
cell = new TableHeaderCell();
cell.ColumnSpan = 6;
cell.Text = "Invoice Info";
cell.Attributes.Add("style", "text-align:center !important;");
row.Controls.Add(cell);
cell = new TableHeaderCell();
cell.ColumnSpan = 5;
cell.Text = "Forwarder Info";
cell.Attributes.Add("style", "text-align:center !important;");
row.Controls.Add(cell);
row.BackColor = System.Drawing.ColorTranslator.FromHtml("#3AC0F2");
row.Height = 50;
GridView1.HeaderRow.Parent.Controls.AddAt(0, row);
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim dt As System.Data.DataTable = New System.Data.DataTable()
dt.Columns.Add("IMp_ID")
dt.Columns.Add("Suppplier_Asset")
dt.Columns.Add("Code")
dt.Columns.Add("Shipping_Line")
dt.Columns.Add("Imp_Date")
dt.Columns.Add("Inv_ID")
dt.Columns.Add("Value")
dt.Columns.Add("Inv_Weight")
dt.Columns.Add("Bales")
dt.Columns.Add("Inv_Currency")
dt.Columns.Add("Inv_Date")
dt.Columns.Add("ID")
dt.Columns.Add("Forwarder")
dt.Columns.Add("Forwarder_Currency")
dt.Columns.Add("Foreign_Value")
dt.Columns.Add("Forwarder_Date")
dt.Rows.Add(1, "Pakistan", "Has", "126000003", "14/05/2021", "ABC-22", "55.00", "545.00", "55", "200.00", "14/05/2021", "INV_003", "Ayhan Shipping", "45.00", "5.54", "14/05/2021")
GridView1.DataSource = dt
GridView1.DataBind()
End If
End Sub
Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As EventArgs)
Dim row As GridViewRow = New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal)
Dim cell As TableHeaderCell = New TableHeaderCell()
cell.Text = "Action"
cell.ColumnSpan = 1
cell.Attributes.Add("style", "text-align:center !important;")
row.Controls.Add(cell)
cell = New TableHeaderCell()
cell.ColumnSpan = 5
cell.Text = "Shipper Info"
cell.Attributes.Add("style", "text-align:center !important;")
row.Controls.Add(cell)
cell = New TableHeaderCell()
cell.ColumnSpan = 6
cell.Text = "Invoice Info"
cell.Attributes.Add("style", "text-align:center !important;")
row.Controls.Add(cell)
cell = New TableHeaderCell()
cell.ColumnSpan = 5
cell.Text = "Forwarder Info"
cell.Attributes.Add("style", "text-align:center !important;")
row.Controls.Add(cell)
row.BackColor = System.Drawing.ColorTranslator.FromHtml("#3AC0F2")
row.Height = 50
GridView1.HeaderRow.Parent.Controls.AddAt(0, row)
End Sub
Screenshot