【发布时间】:2014-10-13 04:08:29
【问题描述】:
在 ASP.NET 网络表单中,有没有办法配置 GridView 的 FooterTemplate 以允许页脚溢出,但也保留上面的列宽度,如下所示?就像现在一样,任何页脚溢出也会拉伸其上方的单元格。
【问题讨论】:
在 ASP.NET 网络表单中,有没有办法配置 GridView 的 FooterTemplate 以允许页脚溢出,但也保留上面的列宽度,如下所示?就像现在一样,任何页脚溢出也会拉伸其上方的单元格。
【问题讨论】:
您可以使用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/
【讨论】: