Click here to Skip to main content
11,484,640 members (60,417 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
When I click the page number then error is

The GridView 'GridView1' fired event PageIndexChanging which wasn't handled.
How to handle it?
When I try
this
protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            GridView1.DataSource = GetData();
            GridView1.DataBind();
        }

during the build error is
'System.EventArgs' does not contain a definition for 'NewPageIndex' and no extension method 'NewPageIndex' accepting a first argument of type 'System.EventArgs' could be found (are you missing a using directive or an assembly reference?)
Posted 27-Nov-11 21:26pm
Edited 27-Nov-11 22:50pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

try this,

in gridview's pageindexChanging property,

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    GridView1.PageIndex = e.NewPageIndex;
 
    //rebind your gridview - GetSource(),Datasource of your GirdView
    GridView1.DataSource = GetSource();
    GridView1.DataBind();
 
}

hope it helps, mark this as answer if it helps you

thanks
  Permalink  
Comments
Prince Antony G at 28-Nov-11 3:40am
   
Try this
sathish kumar at 25-Sep-13 4:31am
   
The name 'GetSource' does not exist in the current context
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Try this:

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    GridView1.PageIndex = e.NewPageIndex;
    GridView1.DataSource = //get datasource (list or datatable)
    GridView1.DataBind(); //bind data
}

-Eduard
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You need to handle the PageIndexChanging event for the grid like

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    GridView1.PageIndex = e.NewPageIndex;
    //Bind grid

}
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

first check
AllowPaging="True" 
or not. if not "True".then make it "true>"

then in ur PageIndexChanging event write this code
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    GridView1.PageIndex = e.NewPageIndex;
    bindData();
}
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

To use paging in GridView you need to take care of following things
1. Give PageSize
2. write PageIndexChanging event
You have not define GridView1_PageIndexChanging in your codebehind
check following code

protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    GridView1.PageIndex = e.NewPageIndex;
    //Bind grid
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 190
1 Sergey Alexandrovich Kryukov 180
2 Raje_ 155
3 OriginalGriff 147
4 Mehdi Gholam 120
0 Sergey Alexandrovich Kryukov 8,484
1 OriginalGriff 7,948
2 Sascha Lefèvre 3,199
3 Maciej Los 2,681
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 28 Nov 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100