Click here to Skip to main content
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 OriginalGriff 490
1 Maciej Los 305
2 Richard MacCutchan 270
3 Mathew Soji 220
4 BillWoodruff 210
0 OriginalGriff 8,834
1 Sergey Alexandrovich Kryukov 7,477
2 DamithSL 5,689
3 Maciej Los 5,329
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411028.1 | Last Updated 28 Nov 2011
Copyright © CodeProject, 1999-2014
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