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

标签 c# .net asp.net html

我有一个与数据集绑定(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/

相关文章:

c# - 如何以编程方式保持wpf中对象的纵横比

c# - 控件应该在 ViewModel 中吗?

c# - 下拉列表值的 request.form

c# - 在Web方法中创建cookie

c# - 从服务器而不是本地驱动器路径在 MVC ASP.NET 中加载 XML 文件

c# - Where 子句中包含 ".Any"的动态 Linq (C#/.Net Core/EF Core)

.Net 在每日构建中检查更新的 AssemblyInfo.cs 是否更好?

c# - 字符 ä 在同一个字符串中以不同的 Char Codes 表示

c# - Observable<string> 更新事件?

asp.net - 页面检查器 : URL must map to a project in the current solution