【问题标题】:ASP.NET Webforms Gridview FooterASP.NET Webforms Gridview 页脚
【发布时间】:2014-10-13 04:08:29
【问题描述】:

在 ASP.NET 网络表单中,有没有办法配置 GridViewFooterTemplate 以允许页脚溢出,但也保留上面的列宽度,如下所示?就像现在一样,任何页脚溢出也会拉伸其上方的单元格。

【问题讨论】:

    标签: c# css gridview webforms


    【解决方案1】:

    您可以使用gridview_rowcreated() 事件来做到这一点。

    如果允许行跨度和列具有所需的列和行

    根据您的要求修改它。

    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            GridView FooterGrid = (GridView)sender;
            GridViewRow FooterRow = new GridViewRow(0, 0, DataControlRowType.Footer, DataControlRowState.Insert);
            TableCell Cell_Footer = new TableCell();
            Cell_Footer.Text =""; // As per your requirement
            Cell_Footer.HorizontalAlign = HorizontalAlign.Center;
            Cell_Footer.ColumnSpan = 2;
            HeaderRow.Cells.Add(Cell_Footer);
    
            Cell_Footer = new TableCell();
            Cell_Footer.Text = ""; // As per your requirement
            Cell_Footer.HorizontalAlign = HorizontalAlign.Center;
            Cell_Footer.ColumnSpan = 1;
            Cell_Footer.RowSpan = 2;
            FooterRow.Cells.Add(Cell_Footer);
    
            Cell_Footer = new TableCell();
            Cell_Footer.Text = ""; // as per your requiremnt
            Cell_Footer.HorizontalAlign = HorizontalAlign.Center;
            Cell_Footer.ColumnSpan = 3;
            FooterRow.Cells.Add(Cell_Footer);
    
            GridView1.Controls[0].Controls.AddAt(0, FooterRow);
    
        }
    }
    

    如果需要更多解释,请点击链接 http://codedisplay.com/merge-merging-or-split-spliting-gridview-header-row-or-columns-in-asp-net-c-vb-net/

    【讨论】:

    • 不是我所需要的,但无论如何感谢,因为它为我指明了正确的方向。
    • @Abbath 你可以根据你的要求跨越。只需在 RowCreated() 事件中执行此操作。并检查 rowtype 必须是页脚。否则它将指向实际的数据行
    猜你喜欢
    • 1970-01-01
    • 2011-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-30
    • 2010-10-27
    相关资源
    最近更新 更多