.net分页方法
//记录分页的总条数
DX.Model.Container.PagerDataContainer Container = new DX.Model.Container.PagerDataContainer();
int ActualPageSize = PageSize;
#region 总页数
int total = 0;
DataSet dsTotal = new DataSet();
StringBuilder sbTotal = new StringBuilder();
if (UserIdentity == 0)
{
sbTotal.Append("select count(UserID) as total FROM [dbo].[tb_e_User] WHERE 1=1"); //查询总条数
}
else
{
sbTotal.Append("select count(UserID) as total FROM [dbo].[tb_e_User] WHERE UserIdentity=" + UserIdentity); //查询总条数
}
 
if (UserIdentity != 0)
{
sbTotal.Append("AND UserIdentity =" + UserIdentity);
}
dsTotal = DX.DBHelper.DbHelperSQL.Query(sbTotal.ToString());
if (dsTotal.Tables.Count > 0)
{
if (dsTotal.Tables[0].Rows.Count > 0)
{
total = Convert.ToInt32(dsTotal.Tables[0].Rows[0]["total"]);
}
}
 
Container = GetContainerPageStr(PageSize, PageIndex, Container, total, out PageSize);
#region 分页数据
StringBuilder sbsql = new StringBuilder();
 
////1为普通用户 2为策划师 3为主持人 4为摄影师 5为摄像师 6为化妆师
sbsql.Append("SELECT ");
sbsql.Append("tab1.UserID,");
sbsql.Append("tab1.LoginNo,");
sbsql.Append("tab1.[RealName],");
sbsql.Append("(SELECT b.CityName FROM dbo.tb_d_Provinces b where b.ProvinceID=tab1.ProvinceID) AS ProvinceName,");
sbsql.Append("(SELECT c.CityName FROM dbo.tb_d_Provinces c where c.ProvinceID=tab1.CityID) AS CityName,");
if (UserIdentity == 3 || UserIdentity == 4 || UserIdentity == 5 || UserIdentity == 6 || UserIdentity == 7 || UserIdentity == 8)
{
sbsql.Append("(SELECT j.CityName FROM dbo.tb_d_Provinces j where j.ProvinceID=tab1.SvrProvinceID) AS SvrProvinceName,");
sbsql.Append("(SELECT k.CityName FROM dbo.tb_d_Provinces k where k.ProvinceID=tab1.SvrCityID) AS SvrCityName,");
}
 
sbsql.Append("tab1.[Address],");
sbsql.Append("tab1.LoginCount,");
sbsql.Append("tab1.RegisterTime,");
sbsql.Append("");
sbsql.Append("tab1.LastLoginTime,");
if (UserIdentity == 2) //策划师
{
sbsql.Append("tab1.Age, ");
sbsql.Append("tab1.Sex, ");
}
if (UserIdentity == 3 || UserIdentity == 4 || UserIdentity == 5 || UserIdentity == 6 || UserIdentity == 7 || UserIdentity == 8) //主持人
{
sbsql.Append("tab1.Age, ");
sbsql.Append("tab1.Sex, ");
if (UserIdentity == 3)
{
sbsql.Append("tab1.BodyHeight, ");
}
sbsql.Append("tab1.WorkYears, ");
sbsql.Append("ISNULL((SELECT x.SvrRMB FROM dbo.tb_e_User_PriceAdju x WHERE x.SRMBID = tab1.SRMBID ) ,0)AS SvrRMB, ");
}
sbsql.Append("tab1.ISLOCK FROM [dbo].[tb_e_User] tab1,");
sbsql.Append("(");
sbsql.Append("SELECT TOP " + PageSize + " UserID FROM ");
sbsql.Append("(");
 
sbsql.Append(" SELECT TOP " + (ActualPageSize * PageIndex) + " UserID FROM [dbo].[tb_e_User] WHERE 1=1 "); //
 
if (UserIdentity != 0)
{
sbsql.Append("AND UserIdentity =" + UserIdentity);
}
 
sbsql.Append("ORDER BY UserID DESC ");
sbsql.Append(" ) p ORDER BY p.UserID ASC ");
sbsql.Append(") ");
sbsql.Append("tab2 WHERE tab1.UserID= tab2.UserID ORDER BY tab1.UserID DESC ");
 
DataSet ds = new DataSet();
ds = DX.DBHelper.DbHelperSQL.Query(sbsql.ToString());
if (ds.Tables.Count > 0)
{
Container.Success = 1;
Container.SuccessStr = "加载成功";
Container.DsList = ds;
}
else
{
Container.DsList = listNull;
}
#endregion
return Container;
 
-------------------------------js分页方法--------------------------------------------------
function UserList(PageIndex,id) {
var param = { action: "CaseList", PageIndex: PageIndex, PageSize: PageSize, id: id, UserIdentity: UserIdentity };//参数拼接
var Resultstr = "";
var PagerStr = "";
Resultstr += "<thead>";
Resultstr += "<tr>";
Resultstr += "<th>用户编号</th>";
Resultstr += "<th>用户姓名</th>";
Resultstr += "<th>用户标题</th>";
Resultstr += "<th>案例类型</th>";
//Resultstr += "<th>视频地址</th>";
Resultstr += "<th>案例价格</th>";
Resultstr += "<th>浏览量</th>";
Resultstr += "<th>案例地址</th>";
Resultstr += "<th>案例时间</th>";
Resultstr += "<th>操作</th>";
if (UserIdentity == 3) {
Resultstr += "<th>案例审核</th>";
} else {
Resultstr += "<th>推荐</th>";
Resultstr += "<th>专项推荐</th>";
Resultstr += "<th>婚礼案例推荐</th>";
Resultstr += "<th>职业人案例推荐</th>";
}
Resultstr += "</tr>";
Resultstr += "</thead>";
Resultstr += "<tbody >";
$.ajax({
type: "Post",
async: true,
cache: false,
url: "/ashx/ZWY.ashx",
data: param,
dataType: "json",
success: function (data) {
 
if (data.Success == 1) {
 
$.each(data.DsList.ds, function (i, item) {
 
currPageIndex = data.PageIndex;
 
Resultstr += "<tr>";
Resultstr += "<td>";
Resultstr += "<a href=\"#\">" + item.CaseID + "</a>";
Resultstr += "</td> ";
Resultstr += "<td>" + item.RealName + "</td>";
Resultstr += "<td>" + item.Title + "</td>";
if (item.Type == 1) {
Resultstr += "<td>普通案例</td>";
} else {
Resultstr += "<td>视频案例</td>";
}
if (item.VideoUrl == "") {
//Resultstr += "<td>--</td>";
} else {
//Resultstr += "<td>" + item.VideoUrl + "</td>";
}
Resultstr += "<td>" + item.Price + "</td>";
Resultstr += "<td>" + item.PageView + "</td>";
//alert(item.RegisterTime);
 
Resultstr += "<td>" + item.Address + "</td>";
Resultstr += "<td>" + item.CaseTime.substring(0,10) + "</td>";
if (UserIdentity == 3) {
Resultstr += "<td><a href='javascript:void(0);' onclick='javascript:DeleteCase(" + PageIndex + "," + item.CaseID + ");'> 删除</a>";
Resultstr += "<a href='/pages/casedetails.aspx?CaseID=" + item.CaseID + "' target=\"_blank\"> 查看</a>";
//Resultstr += "<td><a href='javascript:void(0);' onclick='javascript:AuditPass(" + PageIndex + "," + item.CaseID + ");'> 审核通过</a>";
Resultstr += "<td><a href='javascript:void(0);' onclick='javascript:ShenHe(" + PageIndex + "," + item.CaseID + ");'> 审核通过</a>";
Resultstr += "<a href='javascript:void(0);' onclick='javascript:ShenHe1(" + PageIndex + "," + item.CaseID + ");'> 驳回审核</a>";
 
} else {
Resultstr += "<td><a href='javascript:void(0);' onclick='javascript:DeleteCase(" + PageIndex + "," + item.CaseID + ");'> 删除</a>&nbsp;&nbsp; <a href='/pages/casedetails.aspx?CaseID=" + item.CaseID + "' target=\"_blank\"> 查看</a>&nbsp;&nbsp; </td>";
//Resultstr += "<td><a href='javascript:void(0);' onclick='javascript:Detail(" + item.UserID + ");'>详细</a></td>";
Resultstr += "<td><input type=\"text\" id=\"Rec" + item.CaseID + "\" style=\"width:40px; height:20px; font-size:14px; padding:0;\" value=\"" + item.Recommend + "\">&nbsp;<a href='javascript:void(0);' onclick='javascript:Recommend(" + item.CaseID + ");'>推荐</a></td>";
Resultstr += "<td><input type=\"text\" id=\"Re" + item.CaseID + "\" style=\"width:40px; height:20px; font-size:14px; padding:0;\" value=\"" + item.specialRecommend + "\">&nbsp;<a href='javascript:void(0);' onclick='javascript:specialRecommend(" + item.CaseID + ");'>推荐</a></td>";
Resultstr += "<td><input type=\"text\" id=\"Recc" + item.CaseID + "\" style=\"width:40px; height:20px; font-size:14px; padding:0;\" value=\"" + item.weddingRecommend + "\">&nbsp;<a href='javascript:void(0);' onclick='javascript:WeddingRecommend(" + item.CaseID + ");'>推荐</a></td>";
Resultstr += "<td><input type=\"text\" id=\"Reec" + item.CaseID + "\" style=\"width:40px; height:20px; font-size:14px; padding:0;\" value=\"" + item.ProfessionalRecommend + "\">&nbsp;<a href='javascript:void(0);' onclick='javascript:ProfessionalRecommend(" + item.CaseID + ");'>推荐</a></td>";
}
Resultstr += "</tr>";
 
});
if (data.DsList.ds == "") {
 
Resultstr += "<tr><td colspan=11 style=\"text-align:center;\">暂无数据...</td><tr>";
 
// Resultstr += "<div style=\"float:left; width:300px;border:1px solid red\">暂无数据</div>";
Resultstr += "</tbody>";
$("#dynamic-table").html("");
$("#dynamic-table").html(Resultstr);
} else {
Resultstr += "</tbody>";
$("#dynamic-table").html("");
$("#dynamic-table").html(Resultstr);
}
Resultstr += "</tbody>";
$("#dynamic-table").html("");
$("#dynamic-table").html(Resultstr);
PagerStr += ' <div class="col-xs-6"> ';
PagerStr += ' <div id="dynamic-table_info" class="dataTables_info">共' + data.PageCount + '页 第' + PageIndex + '页 共' + data.TotalCount + '条结果</div> ';
PagerStr += ' </div> ';
PagerStr += ' <div class="col-xs-6"> ';
PagerStr += ' <div id="dynamic-table_paginate" class="dataTables_paginate paging_simple_numbers"> ';
PagerStr += ' <ul class="pagination"> ';
if (PageIndex == 1) {
PagerStr += ' <li class="paginate_button"><a href="javascript:void(0);" onclick="javascript:showtip(\'已经是首页了\');">首 页</a></li> ';
}
else {
PagerStr += ' <li class="paginate_button"><a href="javascript:void(0);" onclick="javascript:PageMode(1);">首 页</a></li> ';
}
 
if (PageIndex != 1) {
PagerStr += ' <li class="paginate_button"><a href="javascript:void(0);" onclick="javascript:PageMode(' + data.PagePre + ');">上一页</a></li> ';
}
else {
PagerStr += ' <li class="paginate_button"><a href="javascript:void(0);" title="上一页" onclick="javascript:showtip(\'上一页没有了\');">上一页</a></li> ';
}
 
if (data.PageCount != PageIndex) {
PagerStr += " <li class=\"paginate_button\"><a href=\"javascript:void(0);\" title=\"下一页\" onclick=\"javascript:PageMode(" + data.PageNext + ");\">下一页</a></li>";
}
else {
PagerStr += ' <li class="paginate_button"><a href="javascript:void(0);" onclick="javascript:showtip(\'下一页没有了\');">下一页</a></li> ';
}
if (PageIndex == data.PageCount) {
PagerStr += ' <li class="paginate_button"><a href="javascript:void(0);" onclick="javascript:showtip(\'已经是最后一页了\');">尾 页</a></li> ';
}
else {
PagerStr += ' <li class="paginate_button"><a href="javascript:void(0);" onclick="javascript:PageMode(' + data.PageCount + ')">尾 页</a></li> ';
}
PagerStr += ' </ul> ';
PagerStr += ' </div> ';
PagerStr += ' </div> ';
$("#pager").empty();
$("#pager").html(PagerStr);
} else {
$("#dynamic-table").html("");
$("#dynamic-table").html("暂无数据");
}
}
});
}

.net分页方法的更多相关文章

  1. Oracle、SQL Server、MySQL分页方法

    测试用例:查询TEST_TABLE表中TEST_COLUMN列的第10-20条数据 1,Oracle分页方法 SELECT A.* FROM ( SELECT ROWNUM ROWNO, B.* FR ...

  2. Sql Server 2012 的新分页方法分析(offset and fetch) - 转载

    最近在分析 Sql Server 2012 中 offset and fetch 的新特性,发现 offset and fetch 无论语法的简洁还是功能的强大,都是相当相当不错的 其中 offset ...

  3. phalcon几种分页方法

    phalcon几种分页方法 一: use Phalcon\Paginator\Adapter\Model as PaginatorModel; // Current page to show // I ...

  4. 只是一个用EF写的一个简单的分页方法而已

    只是一个用EF写的一个简单的分页方法而已 慢慢的写吧.比如,第一步,先把所有数据查询出来吧. //第一步. public IQueryable<UserInfo> LoadPagesFor ...

  5. SharePoint2013 SharePoint-Hosted 模式 分页方法

    /**分页js插件 var ListPager = new listPaging(); 先调用start方法加载上下文 然后调用dataLoad方法查询第一页数据 需要设置几个属性值 ListPage ...

  6. C#针对DataTable进行分页方法

    以下的分页方法是针对数据量不是非常大的数据进行的,是在内存中进行的分页操作. /// <summary> /// DataTable分页 /// </summary> /// ...

  7. SQL SERVER 分页方法

    最近项目中需要在SQL SERVER中进行分页,需要编写分页查询语句.之前也写过一些关于分页查询的语句,但是性能不敢恭维.于是在业务时间,在微软社区Bing了一篇老外写的关于SQL SERVER分页的 ...

  8. sql server两种分页方法

    方法一: --分页方法一 OrderID,CustomerID, EmployeeID,OrderDate,ShippedDate,ShipName,ShipAddress,Freight from ...

  9. Oracle 分页方法研究

    1.Oracle 中的三大分页方法 1.1.通过分析函数分页 1.2.通过 ROWNUM 分页 1.3.通过 ROWID 分页 2.Oracle 分页解决方案浅析 2.1.纯后端代码完成分页 2.2. ...

  10. C# 带偏移量自定义分页方法

    /// <summary> /// 带偏移量自定义分页方法 /// </summary> /// <param name="PageSize"> ...

随机推荐

  1. [BZOJ 4771]七彩树(可持久化线段树+树上差分)

    [BZOJ 4771]七彩树(可持久化线段树+树上差分) 题面 给定一棵n个点的有根树,编号依次为1到n,其中1号点是根节点.每个节点都被染上了某一种颜色,其中第i个节点的颜色为c[i].如果c[i] ...

  2. k8s 组件介绍-kube-schedule

    kubernetes scheduler 基本原理 kubernetes scheduler 作为一个单独的进程部署在 master 节点上,它会 watch kube-apiserver 进程去发现 ...

  3. Windows程序设计(七)--鼠标

    7.2 客户区鼠标消息 当鼠标移过窗口的显示区域时,窗口消息处理程序收到WM_MOUSEMOVE消息.当在窗口的显示区域中按下或者释放一个鼠标按键时,窗口消息处理程序会接收到下面这些消息: 键 按下 ...

  4. ubuntu开发c/c++帮助文档

    1.C语言库函数基本的帮助文档 sudo apt-get install manpages sudo apt-get install manpages-de sudo apt-get install ...

  5. nginx日志切割脚本shell

    nginx-log-rotate.sh: #!/bin/bash#---------------------------------------------# Comment:Used for rot ...

  6. 脚本_监控 HTTP 服务器的状态

    #!bin/bash#功能:监控 HTTP 服务器的状态(测试返回码) #作者:liusingbon#设置变量,url 为你需要检测的目标网站的网址(IP 或域名)url=http://192.168 ...

  7. jsp中引入js文件缓存问题解决

    加上版本UUID <script charset="utf-8" src="${basePath}js/souke/soukegalist.js?v=<%=U ...

  8. Uva10491 Cows and Cars 【迁移自洛谷博客】

    题目大意 假设有a头牛,b辆车(门的总数为a+b),你先选一个门,然后你最终选择前主持人会替你打开C扇有牛的门(不会打开你已经选择的门),问你要不要换门,输出"总是换门"的策略下, ...

  9. phpstorm 各种报错

    1.启动时报错 Failed to load module "canberra-gtk-module" 解决方法:libcanberra-gtk-module sudo apt-g ...

  10. PowerDesigner 小技巧

    PowerDesigner 重现快捷工具栏 palette :Tools -->customsize toolbars-->palette(调色板)勾选 如何在PDM中列表显示TABLE的 ...