SoFunction
Updated on 2025-03-04

A problem encountered with GridView while programming triggered an unhandled event "PageIndexChanging"

A problem encountered with GridView while programming triggered an unhandled event "PageIndexChanging"

Updated: April 3, 2010 17:12:50 Author:
Today, I encountered a very depressing problem when writing code. I created SqlDataSource through programming and bound to GridView. After enabling the paging function of GridView itself, clicking on the paging page number will cause an error message: GridView "GridView1" triggers the unhandled event "PageIndexChanging"...
After studying the problem for a while, I finally found the answer from some online information. The reason should be that the manually programmed data source is not maintained in ViewState. Once PostBack is caused, the content of the data source is lost. The solution is to specify the new page number in the "PageIndexChanging" event of GridView and then re-bind the data source.

The code is as follows:
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
= ;
/* ------ Rewrite the code that previously bound the data source ----- */
}
  • GridView

Related Articles

  • Analysis of MVC drop-down box linkage example

    This article mainly introduces the linkage implementation method of MVC drop-down box. Interested friends can refer to it.
    2016-07-07
  • Insert flash code instance in

    This article introduces inserting flash code instances into it. Friends who need it can refer to it.
    2013-11-11
  • Several ways to implement middleware by Core

    This article introduces several ways to implement middleware by Core, and the article introduces it in detail through sample code. It has certain reference value for everyone's study or work. Friends who need it can refer to it.
    2022-08-08
  • Detailed explanation of the order of event loading on the page

    This article mainly introduces you to the order of event loading on the page. The article introduces the following details through pictures and texts and sample codes, which has certain reference learning value for everyone. Friends who need it, please learn with the editor below.
    2017-08-08
  • HashSet and principle analysis in .NET

    HashSet is defined in it, it is a non-repetitive and disordered generic collection. This article learns the working principle of HashSet. Friends who are interested in HashSet related knowledge in .NET will take a look.
    2022-03-03
  • MVC Basics

    This article mainly introduces basic knowledge such as the basic concept of MVC, the relationship between the three major components of MVC, and the relationship between the webform model and the MVC model. It is an indispensable knowledge point for us to learn MVC, and I hope it will be helpful to everyone.
    2014-10-10
  • .net mvc exceeds the maximum request length

    This article mainly introduces in detail the solution to the .net mvc exceeding the maximum request length, limiting the file upload size. Interested friends can refer to it.
    2016-07-07
  • How to configure connection strings

    In this, you can use two ways to write the configuration of the connection string. See the detailed configuration below
    2013-12-12
  • Brief discussion on how to implement a basic identity authentication in Core

    This article mainly introduces a brief discussion on how to implement a basic identity authentication in Core, which has certain reference value. Interested friends can refer to it.
    2016-12-12
  • Introduction to the use of switch case in C#

    This article mainly introduces the use of switch case in C#. There is an example below, you can refer to it.
    2014-06-06

Latest Comments