In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how the Bootstrap paging style of ASP.NETGridView is, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Revenue.cs revenue classes, including entity models and business logic
Public class Revenue {public Revenue (string country, string revenue, string salesmanager, string year) {this.country = country; this.revenue = revenue; this.salesmanager = year;} public Revenue () {public string country {get; set;} public string revenue {get; set;} public string salesmanager {get; set;} public string year {get; set;} public List GetRevenueDetails (int pagenumber,int maxrecords) {List lstRevenue = new List () String filename = HttpContext.Current.Server.MapPath ("~ / App_Data/country_revenue.csv"); int startrecord = (pagenumber * maxrecords)-maxrecords; if (File.Exists (filename)) {IEnumerable range = Enumerable.Range (startrecord, maxrecords); IEnumerable lines = getFileLines (filename, range); foreach (String line in lines) {string [] row = line.Split (','); lstRevenue.Add (new Revenue (row [0], row [1], row [2], row [3])) } return lstRevenue;} public static IEnumerable getFileLines (String path, IEnumerable lineIndices) {return File.ReadLines (path). Where ((l, I) = > lineIndices.Contains (I));} public int GetTotalRecordCount () {string filename = HttpContext.Current.Server.MapPath ("~ / App_Data/country_revenue.csv"); int count= 0; if (File.Exists (filename)) {string [] data = File.ReadAllLines (filename); count= data.Length;} return count;}}
Default.aspx content:
GridView's Bootstrap paging style $(document) .ready (function () {/ / init bootpag var count = GetTotalPageCount (); $('# page-selection'). Bootpag ({total:count}). On ("page", function (event, num) {GetGridData (num);});}) Function GetGridData (num) {$.ajax ({type: "POST", url: "Default.aspx/GetRevenueDetail", data: "{\" pagenumber\ ":" + num + "}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) {bindGrid (data.d);}, error: function (xhr, status, err) {var err = eval ("(" + xhr.responseText + ")") Alert (err.Message);}} function bindGrid (data) {$("[id*=gvBSPagination] tr") .not (": first") .not (": last") .remove (); var table1 = $('[id*=gvBSPagination]'); var firstRow = "$('[id*=gvBSPagination] tr:first-child')"; for (var I = 0; I < data.length; iTunes +) {var rowNew = $(") RowNew.children (). Eq (0) .text (data [I] .country); rowNew.children (). Eq (1) .text (data [I] .salesmanager); rowNew.children (). Eq (2) .text (data [I] .salesmanager); rowNew.children () .eq (3) .text (data [I] .year); rowNew.insertBefore ($("[id*=gvBSPagination] tr:last-child"));} function GetTotalPageCount () {var mytempvar = 0 Ajax ({type: "POST", url: "Default.aspx/GetTotalPageCount", data: ", contentType:" application/json; charset=utf-8 ", dataType:" json ", async:false, success: function (data) {mytempvar=data.d;}, error: function (xhr, status, err) {var err = eval (" + xhr.responseText + ")"); alert (err.Message);}}); return mytempvar } Bootstrap paging style for ASP.NET GridView
Background code:
Public partial class Default: System.Web.UI.Page {private const int MAX_RECORDS = 5; protected void Page_Load (object sender, EventArgs e) {string filename = Server.MapPath ("~ / App_Data/country_revenue.csv"); if (! IsPostBack) {List revenue = GetRevenueDetail (1); gvBSPagination.DataSource = revenue; gvBSPagination.DataBind () }} [WebMethod] [ScriptMethod (UseHttpGet = false, ResponseFormat = ResponseFormat.Json)] public static List GetRevenueDetail (int pagenumber) {Revenue rv=new Revenue (); List lstrevenue = rv.GetRevenueDetails (pagenumber,MAX_RECORDS); return lstrevenue;} [WebMethod] [ScriptMethod (UseHttpGet = false, ResponseFormat = ResponseFormat.Json)] public static int GetTotalPageCount () {int count=0; Revenue rv=new Revenue (); count= rv.GetTotalRecordCount (); count= count / MAX_RECORDS; return count } protected void gvBSPagination_PreRender (object sender, EventArgs e) {GridView gv = (GridView) sender; GridViewRow pagerRow = (GridViewRow) gv.BottomPagerRow; if (pagerRow! = null & & pagerRow.Visible = = false) pagerRow.Visible = true;}}
Country_revenue.csv
The running result of the project is shown in the figure:
About ASP.NETGridView 's Bootstrap paging style is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.