. NET Paging methods

Source: Internet
Author: User

The. Net paging method//records the total number of bars DX.Model.Container.PagerDataContainer Container = new DX. Model.Container.PagerDataContainer (); int actualpagesize = PageSize; #region Total pages int = 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 "); Query total number of}else{sbtotal.append ("SELECT count (UserID) as complete from [dbo].[ Tb_e_user] WHERE useridentity= "+ useridentity); Query total number of} 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 Paging Data StringBuilder Sbsql = new StringBuilder () &NBSP;////1 for the general User 2 for the Planner 3 for the moderator 4 for the photographer 5 for the cameraman 6 for the makeup artist 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)//planner {Sbsql. Append ("Tab1. Age, "); Sbsql. Append ("Tab1. Sex, ");} if (useridentity = = 3 | | useridentity = = 4 | | useridentity = = 5 | | useridentity = = 6 | | useridentity = = 7 | | Useridentity = = 8)//host {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 ();d s = DX. DBHelper.DbHelperSQL.Query (Sbsql. ToString ()); if (ds. Tables.count > 0) {container.success = 1; CONTAINER.SUCCESSSTR = "Load succeeded"; Container.dslist = ds;} Else{container.dslist = Listnull;} #endregionreturn container; ------------------------------- JS Paging method--------------------------------------------------function UserList (pageindex,id) {var param = {action: " Caselist ", Pageindex:pageindex, Pagesize:pagesize, Id:id, useridentity:useridentity};//parameter stitching var Resultstr =" "; var Pag Erstr = ""; ResultStr + = "<thead>"; ResultStr + = "<tr>"; ResultStr + = "<th> user number </th>"; ResultStr + = "<th> user name </th>"; ResultStr + = "<th> user title </th>"; ResultStr + = "<th> case type </th>";//resultstr + = "<th> video address </th>"; ResultStr + = "<th> case price </th>"; ResultStr + = "<th> browsing volume </th>"; ResultStr + = "<th> case address </th>"; ResultStr + = "<th> case time </th>"; ResultStr + = "<th> operation </th>"; if (useridentity = = 3) {ResultStr + = <th> case audit </th>;} else { ResultStr + = "<th> recommended </th>"; ResultStr + = "<th> Special recommendation </th>"; ResultStr + = "<th> Wedding Case recommendation </th> "; ResultStr + = "<th> Professional case recommendation </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> general case </td>";} else {resultstr + = "<td> video case </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 + "); > Delete </a> "; ResultStr + = "<a href= '/pages/casedetails.aspx? Caseid= "+ Item. Caseid + "' target=\" _blank\ "> View </a>";//resultstr + = "<td><a href= ' javascript:void (0); ' onclick= ' Javascript:auditpass ("+ PageIndex +", "+ Item. Caseid + "); > Audit through </a> "; ResultStr + = "<td><a href= ' javascript:void (0); ' onclick= ' Javascript:shenhe (" + PageIndex + "," + item.) Caseid + "); > Audit through </a> "; ResultStr + = "<a href= ' javascript:void (0); ' onclick= ' javascript:shenhe1 (" + PageIndex + "," + item.) Caseid + "); > Dismiss audit </a> ";  } else {resultstr + =" <td><a href= ' javascript:void (0); ' onclick= ' javascript:d Eletecase ("+ PageIndex +", "+ Item. Caseid + "); > Delete </a>&nbsp;&nbsp; <a href= '/pages/casedetails.aspx? Caseid= "+ Item. Caseid + "' target=\" _blank\ "> View </a>&nbsp;&nbsp; </td> ";//resultstr + =" <td><a href= ' javascript:void (0); ' onclick= ' javascript:detail ("+ Item. UserID + "); > Detailed </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 + "); > Recommended </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 + "); > Recommended </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 + "); > Recommended </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 + "); > Recommended </a></td> ";} ResultStr + = "</tr>";  }); if (data. Dslist.ds = = "") { resultstr + = "<tr><td colspan=11 style=\" text-align:center;\ "> No data ...</td> <tr> ";  //resultstr + =" <div style=\ "float:left; width:300px;border:1px solid red\ "> No data </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 ' > Total ' + data. PageCount + ' page ' + PageIndex + ' page total ' + data. TotalCount + ' results </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 h ref= "javascript:void (0);" onclick= "Javascript:showtip (\ ' is already home page \ ');" > Home </a></li> ';} else {pagerstr + = ' <li class= "Paginate_button" ><a href= "javascript:void (0);" onclick= "Javascript:pagemode (1 );" > Home </a></li> ';}  if (PageIndex! = 1) {pagerstr + = ' <li class= "Paginate_button" ><a HREf= "javascript:void (0);" onclick= "javascript:pagemode (' + data '). Pagepre + '); " > Prev </a></li> ';} else {pagerstr + = ' <li class= "Paginate_button" ><a href= "javascript:void (0);" title= "prev" onclick= "javascript : Showtip (\ ' Previous page did not have a \ '); " > Prev </a></li> ';}  if (data. PageCount! = PageIndex) {pagerstr + = "<li class=\" paginate_button\ "><a href=\" javascript:void (0); \ "Title=\" The next page \ "Onclick=\" Javascript:pagemode ("+ data"). Pagenext + "); \" > Next </a></li> ";} else {pagerstr + = ' <li class= "Paginate_button" ><a href= "javascript:void (0);" onclick= "Javascript:showtip (\ ' The next page does not have a \ '); > Next </a></li> ';} if (PageIndex = = data. PageCount) {pagerstr + = ' <li class= "Paginate_button" ><a href= "javascript:void (0);" onclick= "javascript: Showtip (\ ' is already the last page of \ '); " > Last </a></li> ';} else {pagerstr + = ' <li class= "Paginate_button" ><a href= "javascript:void (0);" onclick= "Javascript:pagemode (' + data. PageCount + ') "> Tail Page </a></li> ';} Pagerstr + = ' </ul> '; Pagerstr + = ' </div> '; Pagerstr + = ' </div> '; $ ("#pager"). empty (); $ ("#pager"). HTML (PAGERSTR);} else {$ ("#dynamic-table"). HTML (""); $ ("#dynamic-table"). HTML ("no Data");}});}

. NET Paging methods

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.