Click here to Skip to main content
15,748,088 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.NET
  <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" >
   <Columns>
  </Columns>
  <HeaderStyle CssClass="titleRow" />
  <RowStyle CssClass="itemRow" />
  </asp:GridView>


and here is my event in the code behind

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

}
Posted
Updated 3-Sep-14 20:29pm
v2
Comments
[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;
grdData.DataBind();
}
 
Share this answer
 
Comments
Linkz_G 4-Sep-14 3:05am    
still no event. The gridview is not posting back when I click on the page number
XML
<asp:GridView ID ="gridView1" runat ="server" AutoGenerateColumns ="false" DataKeyNames="id"AllowPaging="true" PageSize="10" OnPageIndexChanging="gridview1_PageIndexChanging" EmptyDataText="No data Available!!">
   <Columns>

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

   <asp:TemplateField HeaderText ="Header2">
   <ItemTemplate><%#Eval("Name")%></ItemTemplate>
   </asp:TemplateField>



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

        gridView1.PageIndex = e.NewPageIndex;

        binddata();

    }


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