If you’ve set a gridviews AllowPaging attribute to “true”, you’ll notice the following error;
The GridView fired event PageIndexChanging which wasn’t handled
To setup paging with Gridviews, you also need to set the page index property to the new page that you wish to view. This is extremely easy to do. See below for a code example written for aspx page and Code behind page.
At aspx page
<asp:GridView ID="GridView1" runat="server" Width="800px" AllowPaging="True" PageSize="100" OnPageIndexChanging="gvList_PageIndexChanging">
At Code behind page
protected void gvList_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
bindGrid(); // your code to bind the grid view eg sql connection
GridView1 .PageIndex = e.NewPageIndex;
GridView1.DataBind(); }
The GridView fired event PageIndexChanging which wasn’t handled
To setup paging with Gridviews, you also need to set the page index property to the new page that you wish to view. This is extremely easy to do. See below for a code example written for aspx page and Code behind page.
At aspx page
<asp:GridView ID="GridView1" runat="server" Width="800px" AllowPaging="True" PageSize="100" OnPageIndexChanging="gvList_PageIndexChanging">
At Code behind page
protected void gvList_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
bindGrid(); // your code to bind the grid view eg sql connection
GridView1 .PageIndex = e.NewPageIndex;
GridView1.DataBind(); }
Comments
Post a Comment