How to integrate gridview+objectdatasource+aspnetpager
This article mainly shows you "how to integrate gridview+objectdatasource+aspnetpager", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to integrate gridview+objectdatasource+aspnetpager" this article.
Foreground code:
Promotion and demotion
Background code:
Protected void myPage_PageChanged (object sender, EventArgs e)
{
GridViewRow pagerRow = viewIShow.BottomPagerRow
AspNetPager myPage = (AspNetPager) pagerRow.Cells [0] .FindControl ("myPage")
ViewIShow.PageIndex = myPage.CurrentPageIndex-1
}
Protected void viewIShow_DataBound (object sender, EventArgs e)
{
GridViewRow pagerRow = viewIShow.BottomPagerRow
AspNetPager myPage = (AspNetPager) pagerRow.Cells [0] .FindControl ("myPage")
GridView view = (GridView) sender
MyPage.PageSize = view.PageSize
MyPage.CurrentPageIndex = view.PageIndex + 1; / / the GridView paging index starts at 0 and AspNetPager starts at 1.
}
Protected void ObjectDataSource1_Selected (object sender, ObjectDataSourceStatusEventArgs e)
{
DataSet ds = (DataSet) e.ReturnValue; / / the type returned by the ObjectDataSource query method is converted to the type.
GridViewRow pagerRow = viewIShow.BottomPagerRow
AspNetPager myPage = (AspNetPager) pagerRow.Cells [0] .FindControl ("myPage")
If (ds = = null)
{
MyPage.RecordCount = 0
}
Else
{
MyPage.RecordCount = ds.Tables [0] .Rows.Count
}
}
The above is all the content of this article "how to integrate gridview+objectdatasource+aspnetpager". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!