Click here to Skip to main content
15,747,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I click on the page numbers nothing happens. I have my gridview in a user control.
The breakpoint does not even work.

Is there something I am missing?

Here is my gridview html:
  <asp:GridView ID="grdData" runat="server" AutoGenerateColumns="false"             
EmptyDataText="No records" GridLines="none" Width="100%" PageSize="1" AllowPaging="True" OnPageIndexChanging="grdData_PageIndexChanging"    OnSelectedIndexChanged="grdData_SelectedIndexChanged" >
  <HeaderStyle CssClass="titleRow" />
  <RowStyle CssClass="itemRow" />

and here is my event in the code behind

public void grdData_PageIndexChanging(object sender, GridViewPageEventArgs e)
  //actions here

Updated 3-Sep-14 20:29pm
[no name] 4-Sep-14 2:32am    
if AutoGenerateColumns="false" but there is no columns in your design gridview. Your code is not completed hope so. How r u binding this
Linkz_G 4-Sep-14 3:05am    
I am binding in the code behind. The gridview is not posting back when I click on the page number.
aarif moh shaikh 4-Sep-14 3:10am    
First you have to set Columns in design View or Set AutoGenerateColumns="True" than your can apply paging in Gridview with the help of grdData.PageIndex = e.NewPageIndex; grdData.DataBind();

Try it ... You will get Solution your Problem

protected void grdData_PageIndexChanging(object sender, GridViewPageEventArgs e)
grdData.PageIndex = e.NewPageIndex;
Share this answer
Linkz_G 4-Sep-14 3:05am    
still no event. The gridview is not posting back when I click on the page number
<asp:GridView ID ="gridView1" runat ="server" AutoGenerateColumns ="false" DataKeyNames="id"AllowPaging="true" PageSize="10" OnPageIndexChanging="gridview1_PageIndexChanging" EmptyDataText="No data Available!!">

   <asp:TemplateField HeaderText ="Header1">
   <ItemTemplate><%#Container.DataItemIndex +1 %></ItemTemplate>

   <asp:TemplateField HeaderText ="Header2">

And in gridview1_PageIndexChanging event:
protected void gridview1_PageIndexChanging(object sender, GridViewPageEventArgs e)

        gridView1.PageIndex = e.NewPageIndex;



Hope this help...
Share this answer

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900