The example in this article describes the GridView paging problem in asp.net. Share to everyone for your reference. The specific analysis is as follows:
In ASP.net, the GridView is often used for pagination, and in general, there is no problem with the data source control that is brought with Visual Studio.
But if you set the data source for the GridView in code, the first page of the GridView appears normal, and if you click on the second page, you will often see the following error
Tip: The GridView "gridview_test" fires an unhandled event "pageindexchanging".
The solution to this problem is:
1. In the. aspx design page of the GridView, add
Copy Code code as follows:
And
Copy Code code as follows:
Onpageindexchanging= "Gridview_test_pageindexchanging";
That
Copy Code code as follows:
<asp:gridview id= "Gridview_module" runat= "Server" allowpaging= "true" onpageindexchanging= "Gridview_test_" Pageindexchanging ">
2. In the. Aspx.cs page, add the following code:
Copy Code code as follows:
protected void Gridview_test_pageindexchanging (object sender, Gridviewpageeventargs e)
{
Gridview_test_pageindex = E.newpageindex;
Gridview_test. Datasource= "* *"/Set Data source
Gridview_test. DataBind ();
}
3, run the program, the page will not be wrong.
I hope this article will help you with the ASP.net program design.