Reputation: 1950
This is my scenario.
I have a result set in an ASP GridView presented on a webpage. The GridView is displayed on a screen for viewing by a team that needs to see the information.
However, there is a lot of rows to display, so I have enabled auto paging to keep the results on each page...is there a way to automatically change through the pagination?
Thanks
Code:
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub GridView2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView2.SelectedIndexChanged
End Sub
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;/* y
GridView1.DataSource = SqlDataSource1
GridView1.DataBind();
}
End Class
Upvotes: 0
Views: 411
Reputation: 5029
Do you want to update the grid data when the user changes pages? If so, something like this should work:
Add this to the grid:
onpageindexchanged="GridView1_PageIndexChanged"
And this to the code behind:
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataSource = /* your data source */
GridView1.DataBind();
}
Upvotes: 1