将控件添加到分页内容旁边的gridview(asp.net)的页脚

时间:2013-08-09 14:23:23

标签: c# asp.net gridview

那可能吗? 我知道你可以为特定列添加页脚模板,但是你可以在页面旁边的页脚中添加一个控件吗?

1 个答案:

答案 0 :(得分:2)

是的,您需要在Row_Created事件中检查Pager类型的行,如下所示:

private void grdClientServiceType_RowCreated(object sender,   System.Web.UI.WebControls.GridViewRowEventArgs e)
{
    if(e.Row.RowType == DataControlRowType.Pager)
    {
       // Create your control here, button is an example create whatever you want
       Button theButton = new Button();
       theButton.Text = "Click Me";

       // Add new control to the row with the pager via a table cell
       e.Row.Cells[0].ColumnSpan -= 1;
       TableCell td = new TableCell();
       td.Controls.Add(theButton);
       e.Row.Cells.Add(td);
    }
}