.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. 【题解】Intervals

    题目大意   有\(n\)个区间(\(1 \leq n \leq 200\)),第\(i\)个区间覆盖\((a_{i}, b_{i})\)且有权值\(w_{i}\)(\(1 \leq a_{i} &l ...

  2. hdu6354 Everything Has Changed (圆的相交弧长)

    题目传送门 题意: 用一堆圆来切割一个圆心为原点,半径为R的圆A,问切割完毕后圆A外围剩余部分的周长(图中的红线部分). 思路: 首先判定圆与圆A的关系,这题我们只需要与A内切.相交的圆. 然后就是求 ...

  3. (转)yum的$releasever真是太反动了

    Posted on 2009年 10月9日 by JulyClyde 来看这篇文章的人,大都应该同意<Unix编程艺术>中提到的那些观点吧.今天就给大家看一个反例:yum 的 $relea ...

  4. prometheus 笔记

    前言 prometheus 是监控应用软件类似于nagios. 安装 1.官网下载prometheus-2.2.0.linux-amd64压缩包,解压,执行./prometheus即可.这里重要的是配 ...

  5. css解决表格嵌套表格出现多余边框的方法

    这是昨天遇到的问题因为表格里面套了层表格出现了双层的边框,昨天折腾了很久最终才知道有个属性叫 border-style:hidden 可以解决边框冲突! 左边的边框加上了该属性之后

  6. P与C

    P是排列:与次序有关,P(5.3)=5*4*3 C是组合:与次序无关,C(5.3)=(5*4*3)/(3*2*1)

  7. 请求体中需要的true和requests包put请求冲突了

    python  put请求,添加请求头 不知道怎么解决

  8. [BZOJ3625][Codeforces Round #250]小朋友和二叉树 多项式开根+求逆

    https://www.lydsy.com/JudgeOnline/problem.php?id=3625 愉快地列式子.设\(F[i]\)表示权值为\(i\) 的子树的方案数,\(A[i]\)为\( ...

  9. idea中创建.xml文件或别的文件

  10. “TypeError: list indices must be integers or slices, not str”有关报错解决方案