手机版

ASP .NET GridView的引导程序分页样式

时间:2021-09-12 来源:互联网 编辑:宝哥软件园 浏览:

本文实例为大家分享了显示数据表格(一种控件)的引导程序分页样式,供大家参考,具体内容如下

收入。铯收入类,包括实体模型和业务逻辑

公共类收入{公共收入(字符串国家,字符串收入,字符串销售经理,字符串年份){ this.country=countrythis。营收=收入;这个。销售经理=销售经理;今年=年份;}公共收入(){ }公共字符串国家{获取设置;}公共字符串收入{获取设置;}公共字符串salesmanager { get设置;}公共字符串年份{获取设置;} publiclisto营收GetRevenueDetails(int页码,int最大记录数){listo营收lsto营收=newlisto营收();字符串文件名=HttpContext .当前。服务器。mappath(~/App _ Data/country _ income。CSV’);int start record=(页码*最大记录数)-最大记录数;如果(文件。存在(文件名)){ IEnumerableint范围=可枚举。范围(startrecord,max records);ienumerablesting line=getFileLines(文件名,范围);foreach(行中的字符串行){ string[] row=line .拆分(',');第一收入。添加(新收入(行[0],行[1],行[2],行[3]);} }返回LSTRUNION}公共静态IEnumerableString getFileLines(字符串路径,IEnumerableint line indexs){ 0返回文件。读取线(路径)。其中((l,I)=行索引.包含);} public int gettotallercordcount(){ string filename=HttpContext .当前。服务器。mappath(~/App _ Data/country _ income。CSV’);int count=0;如果(文件。存在(文件名)){字符串[]数据=文件ReadAllLines(文件名);计数=数据。长度;}返回计数;} }Default.aspx内容:

% @ Page Language=' c# ' AutoEventWireup=' true '代码在=' default '之前。aspx。cs ' Inherits=' gridviewbootstrapping .默认的"%!DOCTYPE html html xmlns=' http://www .w3。org/1999/XHTML ' head runat=' server ' title GridView的引导程序分页样式/title link href=' style/bootstrap。量滴CSS ' rel='样式表'/脚本src=' http :脚本/jquery-1。8 .2 .js /脚本脚本src=' http :脚本/jquery。bootpag。量滴js /脚本脚本类型='text/javascript' $(文档)。ready(function(){//init bootpag var count=GetTotalPageCount();$(' #页面选择').bootpag({ total:count }).on('page ',function (event,num){ GetGridData(num);});});函数GetGridAta(num){ $ .ajax({ type: 'POST '、URL : '默认值。aspx/GetRevenueDetail '、data : ' \ '页码' ' : ' num ' } '、内容类型: ' application/JSON;charset=utf-8 ',dataType: 'json ',success:函数(数据){ BindGrid(数据。d);},错误:函数(xhr,status,err){ var err=eval('(' xhr。response text '));警报(错误。消息);} });}函数绑定网格(数据){ $('[id *=gvBSPagination]tr ').不是(' :first ').不是(' :last ').移除();var表1=$('[id *=gvBSPagination]');var第一行=' $('[id *=gvBSPagination]tr : first-child ')';for(var I=0;一。数据。长度;I){ var row new=$(' trtd/tdtd/tdtd/TD/tr ');rowNew.children().等式(0).文本(数据[i].国家);rowNew.children().等式(1)。文本(数据[i].收入);rowNew.children().等式(2)。文本(数据[i].销售经理);rowNew.children().等式(3)。文本(数据[i].年份);新行。在($('[id *=gvBSPagination]tr : last-child ')之前插入;} }函数GetTotalPageCount(){ var mytempvar=0;$.ajax({ type: 'POST ',URL : '默认值。aspx/GetTotalPageCount ' ',data: ' ',内容类型: ' application/JSON;charset=utf-8 ',dataType: 'json ',async:false,success:函数(数据){ mytempvar=data.d},错误:函数(xhr,status,err){ var err=eval('(' xhr。response text '));警报(错误。消息);} });返回mytempvar }/script/head body form id=' form 1 ' runat=' server ' div style=' width :670 px;左边距左:auto右边距:汽车;H2风格='文本对齐:中心;ASP .NET GridView的引导程序分页样式/H2 ASP : GridView ID=' Gvbspagination ' runat=' server ' CSS class=' table-分条表-加边框表-精简width=' 660 px ' AllowPaging=' true ' page size=' 5 ' OnPreRender=' gvBSPagination _ PreRender '页面模板div ID=' page-selection ' class='分页居中/div/页面模板/ASP 3360 GridView div ID=' content '/div/div/form/body后台代码:

公共部分类默认:系统网络。ui。page { private const int MAX _ RECORDS=5;受保护的无效页面_加载(对象发送者,事件参数e){ 0字符串文件名=服务器. MapPath(' ~/App _ Data/country _ income。CSV’);if(!IsPostBack){listo营收收入=GetRevenueDetail(1);gvBSPagination .数据源=收入;gvBSPagination .DataBind();} }[WebMethod][脚本方法(UseHttpGet=false,ResponseFormat=ResponseFormat .Json)])公共静态列表收入GetRevenueDetail(内部页码){ 0收入rv=新收入();利斯托营收lsto营收=rv .GetRevenueDetails(页码,MAX _ RECORDS);返回地表温度收益;}[WebMethod][script方法(UseHttpGet=false,ResponseFormat=ResponseFormat .Json)])公共静态int GetTotalPageCount(){ int count=0;收入rv=新收入();计数=rv .gettotallercordcount();count=count/MAX _ RECORDS;返回计数;}受保护的void gvBSPagination_PreRender(对象发送方,事件参数e){ GridView gv=(GridView)发送方;GridView RoW page RoW=(GridView RoW)gv .BottomPagerRowif(页面行!=空页面行.visible==false)页面行.可见=真;} } country _ income。战斗支援车

项目运行结果如图:

如果大家还想深入学习,可以点击这里进行学习,再为大家附3个精彩的专题:

引导程序学习教程

引导程序实战教程

引导程序插件使用教程

以上就是本文的全部内容。希望对大家的学习有帮助,支持我们。

版权声明:ASP .NET GridView的引导程序分页样式是由宝哥软件园云端程序自动收集整理而来。如果本文侵犯了你的权益,请联系本站底部QQ或者邮箱删除。