分页控件-ASP.NET(AspNetPager)
AspNetPager是asp.net中常用的分页控件,下载AspNetPager.dll,添加引用,在工具栏就可以看到AspNetPager控件:
<div class="oa-el-grid-page">
<webdiyer:AspNetPager ID="AspNetPager2" runat="server" CurrentPageButtonClass="current"
OnPageChanging="AspNetPager2_PageChanging" FirstPageText="首页" LastPageText="最后一页"
NextPageText="下一页" PrevPageText="上一页" HorizontalAlign="Center" ShowBoxThreshold="10"
ShowPageIndexBox="Auto" AlwaysShow="True" PageSize="9">
</webdiyer:AspNetPager>
`
</div>
.oa-el-grid-page a, .oa-el-grid-page input[type="submit"] {
background-color: #FFFFFF;
border-color: #EEEEEE;
border-style: solid;
border-width: 1px;
color: #036CB4;
margin: 2px;
padding: 2px 5px;
text-decoration: none;
}
.oa-el-grid-page .current {
background-color: #036CB4;
border-color: #036CB4;
border-right: 1px solid #036CB4;
border-style: solid;
border-width: 1px;
color: #FFFFFF;
font-weight: bold;
margin: 2px;
padding: 2px 5px;
}
public void DataLoad(int pidx)
{
string TiaoJian = " 1=1 ";
if (txtxfd.Value != "")
TiaoJian += " and name like '%" + txtxfd.Value + "%'";
AspNetPager2.RecordCount = new BLL.Sys_card_class().GetCount(TiaoJian); //分页大小、页码、排序列,升序{False}/降序(True),条件
List<Model.Sys_card_class> LRDate = new BLL.Sys_card_class().GetPageList(AspNetPager2.PageSize, pidx, "id", false, TiaoJian);
if (LRDate.Count > )
{
int i = ;
foreach (Model.Sys_card_class LR in LRDate)
{
ContentStr += "<tr>";
ContentStr += "<td width=\"200px\">" + i.ToString() + "</td>";
ContentStr += "<td width=\"310px\">" + LR.id.ToString() + "</td>";
ContentStr += "<td width=\"310px\">" + LR.name.ToString() + "</td>"; ContentStr += "<td width=\"130px\">";
ContentStr += "<a href='Card_class_Edit.aspx?addoredit=edit&id=" + LR.id.ToString() + @"'>编辑</a>";
ContentStr += " <a class=\"linkcss\" href=\"#\" onclick=\"javascript:if(confirm('确定要删除吗?')){DeleMenu('" + LR.id.ToString() + "');}\" title=\"删除\">删除</a>";
ContentStr += " </td>";
ContentStr += "</tr>"; i++;
}
}
} protected void AspNetPager2_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
DataLoad(e.NewPageIndex);
}
例:
/*样式一:<webdiyer:AspNetPager CssClass="oa-el-grid-page"*/ protected void AspNetPager2_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
LoadDataInfo();
}
protected void AspNetPager1_PageChanged(object src, EventArgs e)
{
LoadDataInfo();
}
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %> <webdiyer:AspNetPager ID="AspNetPager1" runat="server" PageSize="9" ShowPageIndexBox="Never"
CssClass="pagination" LayoutType="Ul" PagingButtonLayoutType="UnorderedList" PagingButtonSpacing="0" CurrentPageButtonClass="active" OnPageChanged="AspNetPager1_PageChanged" ShowCustomInfoSection="Never">
</webdiyer:AspNetPager>
/*分页样式*/
.liPager {
width: 100%;
background-color: #F5F5F5;
vertical-align: middle;
text-align: left;
height: 35px;
line-height: 35px;
display: inline-block;
} .liPager li, .liPager a {
font-family: 微软雅黑;
font-size: 12px;
font-weight: bold;
color: white;
text-align: center;
background-color: #1E71B1;
display: inline-block;
width: 30px;
height: 30px;
border-radius: 30px; /* 所有角都使用半径为5px的圆角,此属性为CSS3标准属性 */
-moz-border-radius: 30px; /* Mozilla浏览器的私有属性 */
-webkit-border-radius: 30px; /* Webkit浏览器的私有属性 */
border-radius: 30px 28px 26px 24px; /* 四个半径值分别是左上角、右上角、右下角和左下角 */
} /*======bootstrap风格========*/ .pagination {
display: inline-block;
padding-left:;
margin: 5px 0;
border-radius: 4px;
font-size:14px;
float: right;
} .pagination > li {
display: inline;
} .pagination > li > a, .pagination > li > span {
position: relative;
padding: 6px 12px;
margin-left: -1px;
line-height: 1.42857143;
color: #337ab7;
text-decoration: none;
background-color: #fff;
border: 1px solid #ddd;
} .pagination > li:first-child > a, .pagination > li:first-child > span {
margin-left:;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
} .pagination > li:last-child > a, .pagination > li:last-child > span {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
} .pagination > li > a:focus, .pagination > li > a:hover, .pagination > li > span:focus, .pagination > li > span:hover {
color: #23527c;
background-color: #eee;
border-color: #ddd;
} .pagination > .active > a, .pagination > .active > a:focus, .pagination > .active > a:hover, .pagination > .active > span, .pagination > .active > span:focus, .pagination > .active > span:hover {
z-index:;
color: #fff;
cursor: default;
background-color: #337ab7;
border-color: #337ab7;
} .pagination > .disabled > a, .pagination > .disabled > a:focus, .pagination > .disabled > a:hover, .pagination > .disabled > span, .pagination > .disabled > span:focus, .pagination > .disabled > span:hover {
color: #777;
cursor: not-allowed;
background-color: #fff;
border-color: #ddd;
} .pagination-lg > li > a, .pagination-lg > li > span {
padding: 10px 16px;
font-size: 18px;
} .pagination-lg > li:first-child > a, .pagination-lg > li:first-child > span {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
} .pagination-lg > li:last-child > a, .pagination-lg > li:last-child > span {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
} .pagination-sm > li > a, .pagination-sm > li > span {
padding: 5px 10px;
font-size: 12px;
} .pagination-sm > li:first-child > a, .pagination-sm > li:first-child > span {
border-top-left-radius: 3px;
border-bottom-left-radius: 3px;
} .pagination-sm > li:last-child > a, .pagination-sm > li:last-child > span {
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
} /*分页*/
.pagination a[disabled] {
color: #777;
cursor: not-allowed;
background-color: #fff;
border-color: #ddd;
} .pagination span.active {
z-index:;
color: #fff;
cursor: default;
background-color: #337ab7;
border-color: #337ab7;
}
例2:
/// </summary>
/// <param name="ds">DataSet实例</param>
/// <param name="datalistname">DataList名称</param>
/// <param name="pagesize">分页大小</param>
public static string GetPageNumjxjdc(DataSet ds, DataList datalistname, int pagesize, string bc)
{
PagedDataSource objPds = new PagedDataSource();
objPds.DataSource = ds.Tables[].DefaultView;
objPds.AllowPaging = true;
int total = ds.Tables[].Rows.Count;
objPds.PageSize = pagesize;
int page;
if (HttpContext.Current.Request.QueryString["page"] != null)
page = Convert.ToInt32(HttpContext.Current.Request.QueryString["page"]);
else
page = ;
objPds.CurrentPageIndex = page - ;
datalistname.DataSource = objPds;
datalistname.DataBind();
int allpage = ;
int next = ;
int pre = ;
int startcount = ;
int endcount = ;
string pagestr = "";
string c = bc;
if (page < ) { page = ; }
//计算总页数
if (pagesize != )
{
allpage = (total / pagesize);
allpage = ((total % pagesize) != ? allpage + : allpage);
allpage = (allpage == ? : allpage);
}
next = page + ;
pre = page - ;
startcount = (page + ) > allpage ? allpage - : page - ;//中间页起始序号
//中间页终止序号
endcount = page < ? : page + ;
if (startcount < ) { startcount = ; } //为了避免输出的时候产生负数,设置如果小于1就从序号1开始
if (allpage < endcount) { endcount = allpage; } //页码+5的可能性就会产生最终输出序号大于总页码,那么就要将其控制在页码数之内
pagestr = "共" + allpage + "页 "; pagestr += page > ? "<a href=\"" + HttpContext.Current.Request.CurrentExecutionFilePath + "?page=1&c=" + c + "\">首页</a> <a href=\"" + HttpContext.Current.Request.CurrentExecutionFilePath + "?page=" + pre + "&c=" + c + "\">上一页</a>" : "首页 上一页";
//中间页处理,这个增加时间复杂度,减小空间复杂度
//for (int i = startcount; i <= endcount; i++)
//{
// pagestr += page == i ? " <font color=\"#ff0000\">" + i + "</font>" : " <a href=\"" + HttpContext.Current.Request.CurrentExecutionFilePath + "?page=" + i + "&c=" + c + "&t=" + t + "\">" + i + "</a>";
//}
pagestr += page != allpage ? " <a href=\"" + HttpContext.Current.Request.CurrentExecutionFilePath + "?page=" + next + "&c=" + c + "\">下一页 </a> <a href=\"" + HttpContext.Current.Request.CurrentExecutionFilePath + "?page=" + allpage + "&c=" + c + "\">末页</a>" : " 下一页 末页"; return pagestr;
} /*
RepeaterTeach.DataSource = ds.Tables[].DefaultView;
RepeaterTeach.DataBind();
PageInfo.InnerHtml = GetPageNumjxjdc(ds, RepeaterTeach, ,"");
*/
<p class="jl_fy" id="PageInfo" runat="server">
</p>
分页控件-ASP.NET(AspNetPager)的更多相关文章
- AspNetPager分页控件配置
AspNetPager是asp.net中常用的分页控件,下载AspNetPager.dll,添加引用,在工具栏就可以看到AspNetPager控件: 拖过来之后,设置如下属性: <webdiye ...
- asp.net分页控件
一.说明 AspNetPager.dll这个分页控件主要用于asp.net webform网站,现将整理代码如下 二.代码 1.首先在测试页面Default.aspx页面添加引用 <%@ Reg ...
- PagedDataSource数据绑定控件和AspNetPager分页控件结合使用列表分页
1.引用AspNetPager.dll. 2.放置Repeater数据绑定控件. <asp:Repeater ID="Repeater1" runat="serve ...
- Repeater + 分页控件 AspNetPager 研究
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs ...
- asp.net webform 自定义分页控件
做web开发一直用到分页控件,自己也动手实现了个,使用用户自定义控件. 翻页后数据加载使用委托,将具体实现放在在使用分页控件的页面进行注册. 有图有真相,给个直观的认识: 自定义分页控件前台代码: & ...
- AspNetPager分页控件
AspNetPager分页控件解决了分页中的很多问题,直接采用该控件进行分页处理,会将繁琐的分页工作变得简单化,下面是我如何使用AspNetPager控件进行分页处理的详细代码:1.首先到www.we ...
- AspNetPager 免费分页控件7.5.1版发布!
AspNetPager 免费分页控件7.5.1版发布,本次升级主要内容有: 修正了ShowDisabledButtons为false时html闭合标签丢失的bug:改为从System.Web.UI.W ...
- 【转】AspNetPager分页控件用法
AspNetPager分页控件解决了分页中的很多问题,直接采用该控件进行分页处理,会将繁琐的分页工作变得简单化,下面是我如何使用AspNetPager控件进行分页处理的详细代码: 1.首先到www.w ...
- asp.net 分页-自己写分页控件
去年就发表过asp.net 分页-利用后台直接生成html分页 ,那种方法只是单纯的实现了分页,基本不能使用,那时就想写个自己的分页控件,无奈能力有限.最近有点时间了,就自己做出了这个分页控件.我承认 ...
随机推荐
- WINDOWS下用脚本运行redis和mongodb
开发环境每次开麻烦,又不想建service,用bat最简单 @echo off echo 打开NOSLQ服务 start E:\nosql\mongodb\mongod.exe -dbpath e:\ ...
- 如何使用Iveely的数据存储引擎 Iveely Database
Iveely 数据存储引擎是为Iveely 搜索引擎提供数据存储的机制. 适用于:频繁数据插入.数据读取.数据更改或者删除数据不适合Iveely Database,存储结构是按照搜索引擎数据存储要求( ...
- 一次ssl的手动实现——加密算法的简单扫荡
引言 最近LZ在公司里接了一个活,要发布一些服务给公司的合作伙伴调用.这种工作LZ可谓是轻车熟路,之前已经做了无数服务端.不过与以往不同的是,这次的服务是要发布在互联网上的,因此不能再像之前的套路一样 ...
- Object C学习笔记15-协议(protocol)
在.NET中有接口的概念,接口主要用于定义规范,定义一个接口关键字使用interface.而在Object C 中@interface是用于定义一个类的,这个和.NET中有点差别.在Object C中 ...
- vitualbox 主机与虚拟机能相互访问的设置
1. 桥接网卡 2. 界面名称:802.11n USB Wireless Lan Card 3. 混杂模式:全部允许 4. 接入网线打勾 5. 确定
- bean标签
bean的uri的路径 bean标签是属于struts中的标签,使用要在 Struts 1.3 Libraries中 struts-taglib-1.3.8.jar 中META-INFtld ...
- ansible 配置运行环境
P34 2.3.1 配置ansible的环境 ansible的配置文件是以ini格式存储配置数据的,在ansible中几乎所有的配置都可以通过playbook或者环境变量来重新赋值 运行ansible ...
- Centos下apache启动时httpd: apr_sockaddr_info_get() failed for 报错
今天安装Apache httpd web服务器时,从官方网站上http://www.apache.org/dyn/closer.cgi下载httpd,然后在centos下解压,安装过程分为三部分: ( ...
- Struts-1和2的比较
Struts1和Struts2都是MVC设计模式的经典应用框架,下文从代码,性能,测试,功能等方面对Struts1和Struts2进行简单比较,来看看Struts的高级版本在哪些方面进行了优化. (1 ...
- JS弹出窗口代码大全(详细整理)
1.弹启一个全屏窗口 复制代码代码如下: <html> <body http://www.jb51.net','脚本之家','fullscreen');">; < ...