This example for you to share the GridView bootstrap pagination style for your reference, the specific contents are as follows
Revenue.cs revenue classes, including entity models and business logic
public class Revenue {public Revenue (string country, String Revenue, String SalesManager, String year) {This.cou
ntry = country;
This.revenue = revenue;
This.salesmanager = SalesManager;
This.year = 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<revenue> getrevenuedetails (int pagenumber,int maxrecords) {list<revenue> lstRevenue = new List
<Revenue> ();
string filename = HttpContext.Current.Server.MapPath ("~/app_data/country_revenue.csv");
int Startrecord = (pagenumber * maxrecords)-maxrecords;
if (file.exists (filename)) {ienumerable<int> range = Enumerable.range (Startrecord, maxrecords);
Ienumerable<string> 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<string> Getfilelines (String path, ienumerable<int> lineindices) {return File . ReadLines (Path).
Where ((l, i) => lineindices.contains (i)); public int Gettotalrecordcount () {string filename = HttpContext.Current.Server.MapPath ("~/app_data/country_reven
Ue.csv ");
int count = 0;
if (file.exists (filename)) {string[] data = file.readalllines (filename); count= data.
Length;
return count;
}
}
Default.aspx content:
<%@ Page language= "C #" autoeventwireup= true "codebehind=" Default.aspx.cs "inherits=" Gridviewbootstrappagination.default "%> <! DOCTYPE html>
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> Revenue = getrevenuedetail (1);
Gvbspagination.datasource = revenue;
Gvbspagination.databind (); } [WebMethod] [Scriptmethod (Usehttpget = false, Responseformat = Responseformat.json)] public static List<re
venue> getrevenuedetail (int pagenumber) {Revenue RV = new Revenue (); list<revenue> lstrevenue = RV.
Getrevenuedetails (pagenumber,max_records);
return lstrevenue; [WebMethod] [Scriptmethod (Usehttpget = false, Responseformat = Responseformat.json)] public static int Gettotalpagec
Ount () {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 results of the project run as shown:
If you want to further study, you can click here to learn, and then attach 3 wonderful topics:
Bootstrap Learning Course
Bootstrap Practical Course
Bootstrap Plugin Usage Tutorial
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.