I have a GridView that is bound with a dataset. I have my footer, whichis separated by the column lines. I want to merge 2 columns; how do I do that?
<asp:TemplateField HeaderText="Name" SortExpression="Name">
<ItemTemplate>
...
</ItemTemplate>
<FooterTemplate >
Grand Total:
</div>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Age" SortExpression="Age">
<ItemTemplate>
...
</ItemTemplate>
<FooterTemplate >
<%# GetTotal() %>
</div>
</FooterTemplate>
</asp:TemplateField>
protected void GridView1_OnRowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells.RemoveAt(1);
e.Row.Cells[0].ColumnSpan = 2;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With