0

I have a ICollection class LabCollection with an array list. This array list contains another class LabEntity. LabEntity has properties LabID, LabName etc.

I am binding ICollection class to gridview:

LabCollection objLabCollection = new LabCollection();
gridview.DataSource = objlabCollection;
gridview.DataBind();

I want to apply page indexing / pagination to gridview, how can I do that using the above.

4

1 回答 1

1

在 gridview 标记中设置,AllowPaging=True替换为 10 等任何数字。PageSize=xx

标记:

<asp:GridView ID="gridview" AllowPaging="true" PageSize="10" OnPageIndexChanging="gridview_PageIndexChanging" runat="server" /> 

代码隐藏:

protected void gridview_PageIndexChanging(object sender, GridViewPageEventArgs e){
    FillGrid();
    gridview.PageIndex = e.NewPageIndex;
    gridview.DataBind();
}
于 2012-11-19T17:07:13.710 回答