1

I am trying to paginate a gridview that has been loaded with IEnumerable object a datasource, i have the following error message: the data source does not support server-side data paging

I am not using ObjectDatasource, i populate the gridview with code behind like this:

Gridview.Datasource = MyDataSource;
Gridview.Databind();

MyDatasarce is a IEnumarable list of object. i am using visual studio 2015 and C# 7

stanlagtan
  • 35
  • 7

1 Answers1

0

You will need to add a PageIndexChanging event.

Say your gridview ID is ID="gvMain"

Within the asp:Gridview tag you will have something like

OnPageIndexChanging="gvMain_PageIndexChanging"

Also add AllowPaging="True"

In the code behind you will have something like:

protected void gvMain_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
        gvMain.PageIndex = e.NewPageIndex;
        gvMain.DataBind();
}
Chris Catignani
  • 5,040
  • 16
  • 42
  • 49