asp.net GridView Bootstrap pagination style _ practical tips

Source: Internet
Author: User
Tags eval httpcontext

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.