Click here to Skip to main content
15,910,083 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

This is arun from Chennai, India.

I m doing a simple project in ASP.NET 4. My Gridview displays the data thru Dataset by clicking the Button1.

Everything works fine but whenever I click the second or next page, the data wont display. I need to click again the Button to display it.

Kindly review and let me know the error.

Thanks.

Default.aspx:

C#
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" EnableSortingAndPagingCallbacks="True" 

PageSize="5" OnPageIndexChanging="gvpageindex" >

Default.aspx.cs:
protected void gvpageindex(object sender, GridViewPageEventArgs e)

{ 
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataSource = ds1.GetData();
GridView1.DataBind();
}

protected void Button1_Click(object sender, EventArgs e)

{
GridView1.DataSource = ds1.GetData();
GridView1.DataBind();
}
Posted
Updated 13-Feb-12 20:03pm
v2
Comments
Arunachalam Gurusamy 14-Feb-12 3:41am    
Thank you Sudip Saha,
Its working now. Thanks a lot.

SQL
Have you made sure that the GridView has AutoGenerateColumns set to true?

GridView.AutoGenerateColumns = True
 
Share this answer
 
can you please use 
EnableSortingAndPagingCallbacks="False"
<asp:gridview id="GridView1" runat="server" allowpaging="True" enablesortingandpagingcallbacks="False" xmlns:asp="#unknown">
 
PageSize="5" OnPageIndexChanging="gvpageindex" >
</asp:gridview>
 
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