How to handle paging in gridview data in asp.net

Posted by MohdAnsar under ASP.NET on 10/30/2011 | Points: 10 | Views : 5308 | Status : [Member] | Replies : 2
i m new to asp.net and i m using paging concept in gridview
and i have use this code given below at my .aspx page

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" ShowFooter="True"
onrowcancelingedit="GridView1_RowCancelingEdit"
onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"
onrowupdating="GridView1_RowUpdating" AllowPaging="True" AllowSorting="True" PageSize="3"
onselectedindexchanged="GridView1_SelectedIndexChanged1"
OnPageIndexChanging="GridView1_PageIndexChanging">

-------------------------------------------------------------------
i need this code given below at my cs page but it is not appearing on cs page still i have used OnPageIndexChanging="GridView1_PageIndexChanging" event at aspx page can anybody tell me how can i use it at my cs page
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gridView.PageIndex = e.NewPageIndex;
gridView.DataBind();
}
---------------------------
when i run the this type of error comes

When changing the page on the GridView control:

The GridView 'GridViewID' fired event PageIndexChanging which wasn't handled.

CS1061: 'ASP.default_aspx' does not contain a definition for 'GridView1_PageIndexChanging' and no extension method 'GridView1_PageIndexChanging' accepting a first argument of type 'ASP.default_aspx' could be found (are you missing a using directive or an assembly reference?)


So pls suggest me.

thanks and regards
Ansar




Responses

Posted by: Hmanjarawala on: 11/1/2011 [Member] Bronze | Points: 25

Up
0
Down
do following change on aspx page

instead of
OnPageIndexChanging="GridView1_PageIndexChanging">

write this
OnPageIndexChanging="gridView_PageIndexChanging">

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

MohdAnsar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: MohdAnsar on: 11/1/2011 [Member] Starter | Points: 25

Up
0
Down
thnks for suggestion but still it is not working

as given in my post i have used both event at my aspx page as given below
onselectedindexchanged="GridView1_SelectedIndexChanged1"
OnPageIndexChanging="GridView1_PageIndexChanging"

but only

GridView1_selectedIndexChanged1 event appearing on cs page but GridView1_PageIndexChanging event is not appearing and i need to write
ssome code at this event.

MohdAnsar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response