Get the App
SLTechnology News&Howtos  ›  Development  › 

How to integrate gridview+objectdatasource+aspnetpager

Shulou Source: shulou.com Published: 2022-06-03 06:16:51 11月16日 Update

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!

Tags: Integration content articles code type learning help foreground background method easy to understand more organization knowledge index ribbon industry information information channel channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn OPPO Reno NVidia MySQL Huawei