我有一个与数据集绑定(bind)的 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>
最佳答案
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;
}
}
关于c# - 我可以在 GridView 中合并页脚吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/808468/