Asp.net gridview分页和rowcommand问题

时间:2014-12-10 08:32:46

标签: c# asp.net gridview

我有一个gridview = page size = 10和onrowcommand to grid cliked event in gridview。

<asp:GridView runat="server" ID="gvCourseAssignments" AutoGenerateColumns="false" AllowPaging="true" ShowFooter="false" OnRowCommand="gvCourseAssignments_RowCommand" OnRowDataBound="gvCourseAssignments_RowDataBound" OnPageIndexChanged="gvCourseAssignments_PageIndexChanged" OnPageIndexChanging="gvCourseAssignments_PageIndexChanging" **PageSize="10"** Width="100%">

但是在第二页中,gridview只有2行。但是当我点击按钮或rowcommand时,网格视图会被空行填充,以调整页面大小= 10。但在第二页只有2行。

请帮忙。

2 个答案:

答案 0 :(得分:1)

protected void grdView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    FillGrid();
    grdView.PageIndex = e.NewPageIndex;
    grdView.DataBind();
}

答案 1 :(得分:0)

   protected void gvCourseAssignments_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvCourseAssignments.PageIndex = e.NewPageIndex;
        bindGridview();
        gvCourseAssignments1.DataBind();
    }

如果这样做,请使用您的.cs代码更新您的问题。