发布网友 发布时间:2022-05-19 14:01
共4个回答
懂视网 时间:2022-05-19 18:22
网易风格:
.anpager .cpb {background:#1F3A87 none repeat scroll 0 0;border:1px solid #CCCCCC;color:#FFFFFF;font-weight:bold;margin:5px 4px 0 0;padding:4px 5px 0;}
.anpager a {background:#FFFFFF none repeat scroll 0 0;border:1px solid #CCCCCC;color:#1F3A87;margin:5px 4px 0 0;padding:4px 5px 0;text-decoration:none}
.anpager a:hover{background:#1F3A87 none repeat scroll 0 0;border:1px solid #1F3A87;color:#FFFFFF;}
属性设置:CssClass="anpager" CurrentPageButtonClass="cpb"
--------------------------------------------------------------------------------
拍拍网风格:
首页上一页12345678910...下一页尾页
CSS样式:
代码如下:
.paginator { font: 11px Arial, Helvetica, sans-serif;padding:10px 20px 10px 0; margin: 0px;}
.paginator a {padding: 1px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;margin-right:2px}
.paginator a:visited {padding: 1px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;}
.paginator .cpb {padding: 1px 6px;font-weight: bold; font-size: 13px;border:none}
.paginator a:hover {color: #fff; background: #ffa501;border-color:#ffa501;text-decoration: none;}
属性设置:CssClass="paginator" CurrentPageButtonClass="cpb"
--------------------------------------------------------------------------------
迅雷风格:
首页上一页12345678910...下一页尾页
CSS样式:
代码如下:
.pages { color: #999; }
.pages a, .pages .cpb { text-decoration:none;float: left; padding: 0 5px; border: 1px solid #ddd;background: #ffff;margin:0 2px; font-size:11px; color:#000;}
.pages a:hover { background-color: #E61636; color:#fff;border:1px solid #E61636; text-decoration:none;}
.pages .cpb { font-weight: bold; color: #fff; background: #E61636; border:1px solid #E61636;}
属性设置:CssClass="pages" CurrentPageButtonClass="cpb"热心网友 时间:2022-05-19 15:30
前台:
<webdiyer:AspNetPager SubmitButtonClass="buttons" ID="AspNetPager1" runat="server" AlwaysShow="True" FirstPageText="首页"
NextPageText="下一页" PrevPageText="前一页" LastPageText="尾页" PageSize="15" ShowInputBox="Always"
OnPageChanged="AspNetPager1_PageChanged">
</webdiyer:AspNetPager>
<!-- PageSize="15"定义每页显示数据条数 -->
后台:
/// <summary>
/// 加载事件
/// </summary>
protected void Page_Load(object sender, EventArgs e)
{
BoundList();
}
/// <summary>
/// 全局的变量,分页用的参数数据信息总数
/// </summary>
public static int sumcount;
/// <summary>
/// 绑定信息数据
/// </summary>
private void BoundList()
{
DataTable dt = GetList().Tables[0];//获取数据源
if (dt.Rows.Count > 0)
{
sumcount = dt.Rows.Count;
PagedDataSource pds = new PagedDataSource();
AspNetPager1.RecordCount = sumcount;
pds.AllowPaging = true;
pds.PageSize = AspNetPager1.PageSize;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
pds.DataSource = dt.DefaultView;
this.gridView1.DataSource = pds; //可以绑定到Gridview 、datalist等数据控件上,此处为Gridview
this.gridView1.DataBind();
}
else
{
AspNetPager1.RecordCount = 0;
this.gridView1.DataSource = null;
gridView1.EmptyDataText = "没有相关信息!";
this.gridView1.DataBind();
}
}
/// <summary>
/// 分页控件的翻页事件
/// </summary>
protected void AspNetPager1_PageChanged(object sender, EventArgs e)
{
BoundList();
}热心网友 时间:2022-05-19 16:48
看夜鹰教程网视频教程,教会你自定义分页,想怎么分就怎么分,样式自己控制。热心网友 时间:2022-05-19 18:23
使用DataGridView的话,有属性可以直接配置为分页形式。