我可以在GridView中合并页脚吗?

MrM*_*MrM 4 .net html c# asp.net

我有一个与数据集绑定的GridView.我有我的页脚,由列线分隔.我想合并2列; 我怎么做?

<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>
Run Code Online (Sandbox Code Playgroud)

小智 7

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;

        }

    }
Run Code Online (Sandbox Code Playgroud)