千家信息网

ASP.NETGridView的Bootstrap分页样式是怎样的

发表于:2025-01-31 作者:千家信息网编辑
千家信息网最后更新 2025年01月31日,这篇文章将为大家详细讲解有关ASP.NETGridView的Bootstrap分页样式是怎样的,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。Reven
千家信息网最后更新 2025年01月31日ASP.NETGridView的Bootstrap分页样式是怎样的

这篇文章将为大家详细讲解有关ASP.NETGridView的Bootstrap分页样式是怎样的,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

Revenue.cs收入类,包括实体模型和业务逻辑

 public class Revenue { public Revenue(string country, string revenue, string salesmanager, string year) {  this.country = 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 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内容:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="GridViewBootstrapPagination.Default" %> GridView的Bootstrap分页样式     

ASP.NET GridView的Bootstrap分页样式

后台代码:

 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

项目运行结果如图:

关于ASP.NETGridView的Bootstrap分页样式是怎样的就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

0