The GridView 'GridView1' fired event PageIndexChanging which wasn't handled?

You need to declare a method on your code behind that handles the PageIndexChanging event.

Up vote 1 down vote favorite share g+ share fb share tw.

I have created one master page and one content page called Detail. On Button click event,displaying data in grid view. In gridview,column are autogenerated.

I wanted to show 11 column in gridview,but it is more than page size. What to do for this? I have created sql helper file for database connection code and calling that method,not using sqldatasource for connection.

When I trying to do paging ,getting error: The GridView 'GridView1' fired event PageIndexChanging which wasn't handled. Asp.net link|improve this question asked Oct 30 '11 at 14:52Jui Test1487 42% accept rate.

You need to declare a method on your code behind that handles the PageIndexChanging event. Something similar to this: protected void GridView1_PageIndexChanging (object sender, GridViewPageEventArgs e) { GridView1. PageIndex = e.

NewPageIndex; bindGridView(); //bindgridview will get the data source and bind it again } private void bindGridView() { GridView1. DataSource=getData(); GridView1.DataBind(); } Providing sample code: protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1. PageIndex = e.

NewPageIndex; bindGridView(); //bindgridview will get the data source and bind it again } protected void Page_Load(object sender , EventArgs e) { if(!IsPostBack) bindGridView(); } //this is some sample data private void bindGridView() { DataTable t = new DataTable(); t.Columns. Add("Col1"); t.Columns. Add("Col2"); DataRow r = null; for (int I = 0; I Produces this.

Ya I done that but no effect. Protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { //string s1 = "select * from master"; //DataSet ds = SqlHelper. GetDataSet(CommandType.

Text, s1, "master"); //DataTable table = ds. Tables"master"; //if (table.Rows. Count > 0) //{ // GridView1.

DataSource = ds; // GridView1.DataBind(); //} GridView1. PageIndex = e. NewPageIndex; //Bind grid GridView1.DataBind(); } and aspx file – Jui Test Oct 30 '11 at 15:27 @JuiTest post this code to your answer, not as a comment.

It's more helpful to see it there. – Icarus Oct 30 '11 at 15:33 I can't answer for own question. – Jui Test Oct 30 '11 at 15:43 @JuiTest sorry, I meant add this code to your own question.

– Icarus Oct 30 '11 at 15:53 Thanks Icarus,for your help. Now it is working. – Jui Test Oct 30 '11 at 18:41.

To fix this, I had to take a closer look at my datasource and datakeys. I have a set of records that are returned from SQL Server and what I was doing is binding them to a POCO. This class had several public properties of type Integer.

These Integers were my datakeys on the grid. I replaced their type with a string instead to bypass the casting issue.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions