为了解决这个问题,我采用了一种我在这里找到的方法:ASP.NET GridView Newbie Questions About TFOOT and TH
要包含分页所需的自定义 div 标签,结果是:
protected void onRowCreate(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
int colSpan = e.Row.Cells.Count;
for (int i = (e.Row.Cells.Count - 1); i >= 1; i -= 1)
{
e.Row.Cells.RemoveAt(i);
e.Row.Cells[0].ColumnSpan = colSpan;
}
e.Row.Cells[0].Controls.Add(new LiteralControl("<ul class='pagination pagination-centered hide-if-no-paging'></ul>"));
}
}
所以在 GridView 声明中调用它,在 'onRowCreated'
<asp:GridView ID="gridViewClientes" ShowFooter="true" OnRowCreated="onRowCreate">
不要忘记在 tablePrerender 上调用它,以正确创建 TFOOT:
gridViewClientes.FooterRow.TableSection = TableRowSection.TableFooter;
注意:我实际上必须将 DIV 元素从可脚注示例更改为 UL 元素才能正常工作。