Home Web Front-end JS Tutorial JS Ajax Jquery implements page refresh-free paging and grouping, super powerful implementation

JS Ajax Jquery implements page refresh-free paging and grouping, super powerful implementation

May 16, 2016 pm 06:47 PM
Pagination No refresh page

<%@ Page language="c#" Codebehind="GroupText.aspx.cs" AutoEventWireup="false" 
Inherits="test1.GroupText" %> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 
4.0 Transitional//EN" > 
<HTML> 
    <HEAD> 
        <title>GroupText</title> 
        <meta 
name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"> 
        <meta name="CODE_LANGUAGE" Content="C#"> 
        <meta 
name="vs_defaultClientScript" content="JavaScript"> 
        <meta 
name="vs_targetSchema" 
content="http://schemas.microsoft.com/intellisense/ie5"> 
        <LINK 
href="css/wmh.css" href="css/wmh.css" type="text/css" rel="stylesheet"> 
        <script src="js/jquery.js" 
type="text/javascript"></script> 
        <script 
src="js/Common.js" type="text/javascript"></script> 
        <script src="js/getCommonTable.js" 
type="text/javascript"></script> 
        <script 
src="js/GroupText.js" type="text/javascript"></script> 
        <script language="javascript"><!-- 
        var ecid = 
&#39;100001&#39;; 
        var jpstr = ""; 
        var pageSize = 8; 

         
// --></script> 

    </HEAD> 
    <body MS_POSITIONING="GridLayout"> 
        <form id="Form1" 
method="post" runat="server"> 
            <div class="listDiv" 
style="height:100%; PADDING-TOP: 2px"> 
                <table 
cellSpacing="0" cellPadding="0" width="100%" border="0"> 
                    <tr class="dg_header"> 
                        <td style="BORDER-RIGHT: 1px solid; BORDER-TOP: 
1px solid; BORDER-LEFT: 1px solid; WIDTH: 10%; BORDER-BOTTOM: 1px solid; 
TEXT-ALIGN: center" >活动名称</td> 
                        <td 
style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; WIDTH: 10%; 
BORDER-BOTTOM: 1px solid; TEXT-ALIGN: center">发送方</td> 
                        <td style="BORDER-RIGHT: 1px solid; BORDER-TOP: 
1px solid; WIDTH: 10%; BORDER-BOTTOM: 1px solid; TEXT-ALIGN: 
center">接收方</td> 
                        <td 
style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; WIDTH: 12%; 
BORDER-BOTTOM: 1px solid; TEXT-ALIGN: center">发送时间</td> 
                        <td style="BORDER-RIGHT: 1px solid; BORDER-TOP: 
1px solid; WIDTH: 38%; BORDER-BOTTOM: 1px solid; TEXT-ALIGN: 
center">发送内容</td> 
                        <td 
style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; WIDTH: 10%; 
BORDER-BOTTOM: 1px solid; TEXT-ALIGN: center">积分</td> 
                        <td style="BORDER-RIGHT: 1px solid; BORDER-TOP: 
1px solid; WIDTH: 10%; BORDER-BOTTOM: 1px solid; TEXT-ALIGN: 
center">状态</td> 
                    </tr> 
                    <tr> 
                        <td 
class="dg_line" style="BORDER-BOTTOM: 0px solid" style="BORDER-BOTTOM: 0px 
solid" vAlign="top" width="100%" colSpan="7" 
                            height="100%"> 
                            <div id="divcontent" style="WIDTH: 100%; 
HEIGHT: 100%" align="left"></div> 
                        </td> 
                    </tr> 
                    <tr> 
                        <td 
class="dg_line" style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; 
BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid" style="BORDER-RIGHT: 1px 
solid; BORDER-TOP: 1px solid; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid" 
                            width="100%" colSpan="10"> 
                            <table width="100%"> 
                                <tr> 
                                    <td class="pgtext">共<span 
id="recordcount" style="COLOR: red" style="COLOR: red">0</span>条记录    
                                        目前第<span id="curpageindex" 
style="COLOR: red" style="COLOR: red">0</span> <font 
color="red">/</font><span id="pgcount" style="COLOR: red" 
style="COLOR: red">0</span>页    
                                        <input class="pageText" 
id="gototxt" type="text" maxLength="10" name="gototxt" runat="server"> 
                                        <input id="gotopg" type="button" 
class="goBtn"></td> 
                                    <td 
align="right"><IMG id="btnfirst" style="CURSOR: hand" style="CURSOR: hand" 
alt="首页" src="Images/first.gif"> 
                                        <IMG id="btnpre" style="CURSOR: 
hand" style="CURSOR: hand" alt="上一页" src="Images/btn_pre.gif" > <IMG 
id="btnnext" style="CURSOR: hand" style="CURSOR: hand" alt="下一页" 
src="Images/btn_next.gif" > 
                                        <IMG id="btnlast" style="CURSOR: 
hand" style="CURSOR: hand" alt="尾页" src="Images/btn_last.gif" > 
                                    </td> 
                                </tr> 
                            </table> 
                        </td> 
                    </tr> 
                </table> 
            </div> 
        </form> 
    </body> 
</HTML>
Copy after login

Common.js

Common.js: 
//时间格式化 

function getDateByFormat(oldDate){ 
                var Dy = oldDate.getFullYear(); 
                var Dm = 
oldDate.getMonth()+1; 
                var Dd = oldDate.getDate(); 
                if(Dm<10){ 
                    Dm = "0" + Dm; 
                } 
                if(Dd<10){ 
                    Dd = "0" + Dd; 
                } 
                var newDate = Dy+&#39;-&#39;+Dm+&#39;-&#39;+Dd; 

                    return newDate; 
                } 
//日期-时间格式化 
function getDateTimeByFormat(oldDate){ 
                var Dy = 
oldDate.getFullYear(); 
                var Dm = oldDate.getMonth()+1; 
                var Dd = oldDate.getDate(); 
                var Dh = 
oldDate.getHours(); 
                var Dmi = oldDate.getMinutes();   
                var Ds    = oldDate.getSeconds();    
                if(Dm<10) 
                    Dm = "0" + Dm; 
                if(Dd<10) 
                    Dd = "0" + Dd; 

                if(Dh<10) 
                 Dh = "0" + Dh; 
                if(Dmi<10) 
                    Dmi = "0" + Dmi; 
                if(Ds<10) 
                    Ds = "0" + Ds; 

                var newDate = Dy+&#39;-&#39;+Dm+&#39;-&#39;+Dd+&#39; &#39;+Dh+&#39;:&#39;+Dmi+&#39;:&#39;+Ds; 
                    return newDate; 
                } 

//只能输入数字 
function txtnumber() 
            { 
                if 
((event.keyCode >57) || (event.keyCode <48)) 
                    return false;else return true; 
            } 

        //只能输入数字和字母 

    function txtnumchar() 
            { 
//65- 90 97-122 
                var kcode = event.keyCode; 
                if (kcode >= 48 && kcode <= 57) 
                    return true; 
                else if(kcode >= 65 
&& kcode <= 90) 
                    return true; 
                else if (kcode >= 97 && kcode <= 122) 
                    return true; 
                else 
                    return false; 
            }
Copy after login

getCommonTable.js 

getCommonTable.js 
//获取table头 
         function 
getTableHeadByWidth(widthSize,ids){ 
         var Tableone = "<table 
id=&#39;tab"+ids+"&#39; border=&#39;0&#39; cellspacing=&#39;0&#39; cellpadding=&#39;0&#39; "; 
         var 
Tabletwo = ">"; 
         if (widthSize == "") 
         return 
Tableone + Tabletwo; 
         else 
         return 
Tableone+"width="+widthSize+Tabletwo; 

        } 

         
//获取第一个tr td 传一个宽度值 
        function 
getTrAndTdFirstByCWidth(classname,widthSize){ 
         var tdone = " <tr 
"; 
         var tdtwo = "><td style="BORDER-BOTTOM: 1px solid;" 
style="BORDER-BOTTOM: 1px solid;" align=&#39;center&#39; "; 
         var tdthr = " 
> "; 
         if (classname =="") 
         tdone += tdtwo; 
         else 
         tdone+=" class =&#39;"+classname+"&#39; "+tdtwo; 

         if (widthSize == "") 
         tdone += tdthr; 
         else 
         tdone += " width="+widthSize+tdthr; 

         return 
tdone; 
        } 

        //获取下一个TD,传一个宽度值 
        function 
getTdNextByWidth(widthSize){ 
         var tdone = " </td><td 
style=" BORDER-BOTTOM: 1px solid" style=" BORDER-BOTTOM: 1px solid" 
align=&#39;center&#39; "; 
         var tdtwo =">"; 
         if (widthSize 
=="") 
         return tdone+tdtwo; 
         else 
         return 
tdone+"width="+widthSize+tdtwo; 
        } 

        //获取最后一个td 
        function getTdLastByWidth(widthSize){ 
         var tdone = 
" </td><td style=" BORDER-BOTTOM: 1px solid" style=" BORDER-BOTTOM: 1px 
solid" align=&#39;center&#39; "; 
         var tdtwo =">"; 
         if 
(widthSize =="") 
         return tdone+tdtwo; 
         else 
         return tdone+"width="+widthSize+tdtwo; 
        } 
        //获取最后一个tr/td 
        function getTrAndTdLast(){ 
         return 
" </td></tr>"; 
        } 

         
        //获取table尾 
        function getTableLast(){ 
         return "</table>"; 
        } 

        //获取img 
        function 
getImgByParams(imgUrl,altstr,eventName,eventParams,imgid){ 
         var one 
= "<img border=&#39;0&#39; style="CURSOR: hand" style="CURSOR: hand""; 
         if (imgUrl != "") 
         one += "src=&#39;"+imgUrl+"&#39;"; 
         if 
(altstr != "") 
         one += "alt=&#39;"+altstr+"&#39;"; 
         if(imgid != 
"") 
         one += "id=&#39;"+imgid+"&#39;"; 

         one += 
"onclick=&#39;"+eventName+"("+eventParams+");&#39;> "; 

         return one 
        } 

//--------排序--------------------------- 
            //通过字段的内容排序 
        SortByBtnidAndCellName=function(btnId,cellName,celltype){ 
            var way =    getOpType(btnId);//0为正。1为倒 
            var ds = 
userdata.value; 
            var sortarr= new Array(); 
            if 
((ds!= null) && (typeof(ds) == "object")){ 
             var len = 
ds.Rows.length; 
             if(celltype==&#39;S&#39; || celltype==&#39;N&#39;){ 
                        for(var j=0;j<len;j++){ 
                            sortarr[j] = 
ds.Rows[j][cellName];//.substr(0,1);//通过字符 
                            } 
                    }else if(celltype==&#39;D&#39;){ 
                        for(var i=0;i<len;i++){ 
                                    sortarr[i] = 
getDateByFormat(ds.Rows[i][cellName]);//通过日期 
                            } 
                    } 
                if(sortarr!=&#39;&#39;){ 
                    var indexarr = new Array(); 
                    indexarr = getSortArray(sortarr,celltype);//得到新的排序规则 
                    if(indexarr != &#39;&#39;){ 
                        setSortAginbyWay(indexarr,way); 
                    } 
                } 
            } 
        } 

        //获得排序 
        getOpType=function(btnid){//返回0正序,1为倒序 
            var imgName= $("#"+btnid).attr("src"); 
            var wz = 
imgName.indexOf(&#39;.gif&#39;); 
            var oldImg =imgName.substr(wz-9,9); 
            if(oldImg==&#39;sort_desc&#39;){//当前是倒序或未排序,需要正序sort_ascc 
                $("#"+btnid).attr("src","../Images/sort_ascc.gif"); 
                return 0; 
            }else{ 
                $("#"+btnid).attr("src","../Images/sort_desc.gif"); 
                return 1; 
            } 

        } 
        //按JS Sort排序 获得新的排序规则 
        getSortArray=function 
(sortdatearr,celltype){// 参数为array 
                var sortstr = &#39;&#39;; 
                for(var k=0;k<sortdatearr.length;k++){ 
                if(sortstr==&#39;&#39;) 
                        sortstr=sortdatearr[k]; 
                    else 
                        sortstr+=&#39;^%^&#39;+sortdatearr[k]; 
                } 
                var newsortdate =sortdatearr; 
                var len = 
sortdatearr.length; 

                    if(celltype ==&#39;S&#39; || celltype 
==&#39;D&#39;) 
                        newsortdate.sort();//字符排序 
                    else{ //数字排序 
                        for(var 
i=0;i<len;i++){ 
                            var tmp =0; 
                            for(var j=i+1;j<len;j++){ 
                                if(newsortdate[i]>newsortdate[j]){ 
                                    tmp = newsortdate[i]; 
                                    newsortdate[i] = newsortdate[j]; 
                                    newsortdate[j] =tmp; 
                                } 
                            } 
                        } 
                    } 

             var 
tmpsortdate =sortstr.split(&#39;^%^&#39;) 

             var resultarr = new 
Array(); 
             for(var i = 0;i<len;i++){ 
                    for(var j = 0;j<len;j++){ 
                     if(newsortdate[i]==tmpsortdate[j]){ 
                            resultarr[i] 
= j; 
                            tmpsortdate[j] =&#39;||||||||&#39;; 
                            break; 
                     } 
                    } 
             } 

             return 
resultarr; 
        }; 

//--------------------end------------------------------- 
//删除重复的手机号码 
SplitRepeatMobile=function(mobile){ 
    var mob=mobile; 
    for(var 
i=0;i<mob.length;i++){ 
        for(var j=i+1;j<mob.length;j++){ 
            if(mob[i]==mob[j]){ 
                mob.splice(j,1); 
            } 
        } 
    } 
    return mob; 
}
Copy after login
GroupText.js 

        var totalCount;//总页 
var userdata;//数据对象 
    $(document).ready(function(){             

             
            if(ecid !=""){ 
             firstSearch(ecid); 
            } 

            $("#ddlCsList").change(function(){ 
             ecid = $.trim($("#ddlCsList").val()); 
             firstSearch(ecid); 
            }); 

            $("#btnfirst").click(function(){ 
         firstSearch(ecid); 
            }); 

            $("#btnnext").click(function(){ 
             nextSearch(ecid); 
            }); 

            $("#btnpre").click(function(){ 
             preSearch(ecid); 
            }); 

            $("#btnlast").click(function(){ 
             lastSearch(ecid); 
            }); 

            $("#gotopg").click(function(){ 
             gotoSearch(ecid); 
            }); 

         

}); 
//绑定数据 
        function binddata(udata) 
        { 
         jpstr 
="";//这样的目的是清空,很有用的一步 

         var ds = udata.value; 

                    if ((ds!= null) && (typeof(ds) == "object")) 
                    { 
                     //alert( ds.Rows[0].ItemName 
) 
                     var c = ds.Rows.length; 
                     var 
newarr = getdataarr(udata); 
                     for(var k = 0; 
k<newarr.length;k++){ 

                             
                            var tmp = newarr[k]; 
                            jpstr +="<tr><td style=" BORDER-BOTTOM: 
1px solid" style=" BORDER-BOTTOM: 1px solid"><IMG id 
=&#39;"+ds.Rows[tmp].srId+"&#39; onclick=showOrHide("+ds.Rows[tmp].srId+") 
style="CURSOR: hand" style="CURSOR: hand" src="Images/uuu.gif" 
src="Images/uuu.gif"><B>"+ds.Rows[tmp].ItemName+"</b></td></tr><tr><td>" 
                            var jpstrA=""; 
                            for(var i=tmp; i<c; i++) 
                            { 

                             if(ds.Rows[tmp].ItemName == ds.Rows[i].ItemName ){ 
                                            jpstrA += 
getTrAndTdFirstByCWidth("dg_item","10%") + 
                                                            ""+ds.Rows[i].ItemName 
+ getTdNextByWidth("10%") + 
                                                            ""+ds.Rows[i].SendMod 
+ getTdNextByWidth("10%") + 
                                                            ""+ds.Rows[i].RecvMod 
+ getTdNextByWidth("12%") + 
                                                            ""+getDateByFormat(ds.Rows[i].SendDate) 
+ getTdNextByWidth("38%") + 
                                                            ""+ds.Rows[i].SendMsg 
+ getTdNextByWidth("10%") + 
                                                            ""+ds.Rows[i].JfValue 
+ getTdLastByWidth("10%") + 
                                                            ""+getTextByStatus(ds.Rows[i].SendStatus) 
+ 
                                                            "" + 
getTrAndTdLast(); 
                                        } 
                                }     

                                jpstr 
+=getTableHeadByWidth("100%",ds.Rows[tmp].srId) + jpstrA + getTableLast(); 

                                jpstr += "</td></tr>"; 

                        } 
                        jpstr ="<table 
width=100%>"+jpstr+"</table>"; 

                             

                                document.getElementById("divcontent").innerHTML 
= jpstr; 
                                //alert(jpstr); 

                } 
                else 
                { 
                    document.getElementById("divcontent").innerHTML = 
"";     
                } 

} 
showOrHide=function(ids){ 
            $("#tab"+ids).toggle(); 
            var imgName= 
$("#"+ids).attr("src"); 

                var wz = 
imgName.indexOf(&#39;.gif&#39;); 
                var oldImg =imgName.substr(wz-3,3); 

                if(oldImg==&#39;uuu&#39;)//选择 
                        $("#"+ids).attr("src","Images/eee.gif"); 
                else{ 
                    $("#"+ids).attr("src","Images/uuu.gif"); 

                    } 

} 
function getdataarr(udata){ 
var 
ds = udata.value; 
            var resultArr= new Array(); 
            var dsstr=&#39;&#39;; 
            for(var i=0; i<ds.Rows.length; 
i++){ 
                resultArr[i] = $.trim(ds.Rows[i].ItemName); 
                if(dsstr==&#39;&#39;) 
                 dsstr 
=$.trim(ds.Rows[i].ItemName); 
                 else 
                 dsstr+=&#39;^%^&#39;+$.trim(ds.Rows[i].ItemName) 
            } 

            splitStr(resultArr) 

            var newArr = new 
Array(); 
            var temparr=dsstr.split(&#39;^%^&#39;) 
            for(var 
k=0;k<resultArr.length;k++){ 
                for(var 
m=0;m<temparr.length;m++){ 
                    if(resultArr[k]==temparr[m]){ 
                        newArr[k]=m; 
                        break; 
                    } 
                } 
            } 

            return newArr; 
} 
splitStr= function(oldarr){ 
                var nArr=oldarr; 
                var isok=false; 
                for(var l=0;l<nArr.length;l++){ 
                    for(var j=l+1;j<nArr.length;j++){ 
                    if(nArr[l]==nArr[j]){ 
                        nArr.splice(j,1); 
                        isok=true; 
                        }     
                } 
            } 

            if(isok) 
                splitStr(nArr); 

} 
function 
getTextByStatus(status){ 
            if(status==0){ 
             return 
"<font color=&#39;blue&#39;>启用</font>"; 
}else{ 
             return 
"<font color=&#39;red&#39;><B>禁用</B></font>"; 
} 
} 
function getImgByStatus(status){ 
if(status==0){ 
return 
"../Images/gz2.gif"; 
}else{ 
return "../Images/gz1.gif"; 
} 
} 
function getTxtByStatus(status){ 
if(status==0){ 
return "我要禁用"; 
}else{ 
return "我要启用"; 
} 
} 
//第一页 
        function 
firstSearch(ecid) 
        { 
         if (ecid != ""){ 
                 totalCount = Interactive.GetCmdSMSlogCount("1=1").value; 
                    userdata = 
Interactive.PageingOpenCmdSMSLog(1,pageSize);//Interactive.getInteractiveSMSByEcid(ecid,pageSize,1,totalCount); 

                    binddata(userdata); 

                    $("#recordcount").html(totalCount.toString());//curpageindex 
                    $("#curpageindex").html(totalCount==0?&#39;0&#39;:1); 
                    if (totalCount % pageSize ==0) 
                    { 
                     $("#pgcount").html((totalCount / pageSize).toString()); 
                    }else{ 
                     $("#pgcount").html(parseInt(totalCount / pageSize)+1); 
                    } 

                } 
        } 
    //下一页 
        function 
nextSearch(ecid){ 
         if (ecid != ""){ 
         var curpg 
=$("#curpageindex").html();//得到当前页 
         var pgCount = 
$("#pgcount").html();//得到总的页数 
         if (curpg < pgCount){ 
                        totalCount = 
Interactive.GetCmdSMSlogCount(&#39;1=1&#39;).value; 
                     userdata = 
Interactive.PageingOpenCmdSMSLog(parseInt(curpg)+1,pageSize); 

                        binddata(userdata); 
                        $("#recordcount").html(totalCount);//curpageindex 
                        $("#curpageindex").html(parseInt(curpg)+1); 
                        if (totalCount % pageSize ==0) 
                        { 
                        $("#pgcount").html(totalCount / pageSize); 
                        }else{ 
                            $("#pgcount").html(parseInt(totalCount / 
pageSize)+1); 
                        } 
                    }else{ 
                     alert("当前已经是尾页了!"); 
                    } 
                } 
        } 
    //上一页 
        function 
preSearch(ecid){ 
         if (ecid != ""){ 
         var curpg 
=$("#curpageindex").html();//得到当前页 
         var pgCount = 
$("#pgcount").html();//得到总的页数 
         if (curpg > 1 ){ 
                        totalCount = 
Interactive.GetCmdSMSlogCount(&#39;1=1&#39;).value; 
                     userdata = 
Interactive.PageingOpenCmdSMSLog(parseInt(curpg)-1,pageSize); 
                        binddata(userdata); 
                        $("#recordcount").html(totalCount);//curpageindex 
                        $("#curpageindex").html(parseInt(curpg)-1); 
                        if (totalCount % pageSize ==0) 
                        { 
                        $("#pgcount").html(totalCount / pageSize); 
                        }else{ 
                            $("#pgcount").html(parseInt(totalCount / 
pageSize)+1); 
                        } 
                    }else{ 
                         alert("当前已经是首页了!"); 
                    } 
                } 
        } 
        //尾页 
        function 
lastSearch(ecid){ 
         if (ecid != ""){ 
         var curpg 
=$("#curpageindex").html();//得到当前页 
         var pgCount = 
$("#pgcount").html();//得到总的页数 
         if (curpg < pgCount ){ 
                        totalCount = 
Interactive.GetCmdSMSlogCount(&#39;1=1&#39;).value; 
                     userdata = 
Interactive.PageingOpenCmdSMSLog(pgCount,pageSize); 
                        binddata(userdata); 
                        $("#recordcount").html(totalCount);//curpageindex 
                        $("#curpageindex").html(pgCount); 
                        if (totalCount % pageSize ==0) 
                        { 
                        $("#pgcount").html(totalCount / pageSize); 
                        }else{ 
                            $("#pgcount").html(parseInt(totalCount / 
pageSize)+1); 
                        } 
                    } 
                } 

        } 

        //跳转指定页 
        function gotoSearch(ecid){ 
         if (ecid != ""){ 
         var curpg =$("#curpageindex").html();//得到当前页 
         var 
pgCount = $("#pgcount").html();//得到总的页数 
         var pggoto 
=$("#gototxt").val(); 
         var reg = /[^\d]/g; 
                    if (($.trim(pggoto) != "") && 
!(reg.test(pggoto))){ 
                        if ((parseInt(curpg) != 
parseInt(pggoto)) && (pggoto <= pgCount)){ 
                            totalCount = 
Interactive.GetCmdSMSlogCount(&#39;1=1&#39;).value; 
                            userdata = 
Interactive.PageingOpenCmdSMSLog(pggoto,pageSize); 
                            binddata(userdata); 
                            $("#recordcount").html(totalCount);//curpageindex 
                            $("#curpageindex").html(pggoto); 
                            if (totalCount % pageSize ==0) 
                            { 
                            $("#pgcount").html(totalCount / pageSize); 
                            }else{ 
                                $("#pgcount").html(parseInt(totalCount / 
pageSize)+1); 
                            } 
                        } 
                    }else{ 
                        alert("请输入正确的数字!"); 
                    } 

                } 

        } 

        //刷新 
        function Refresh(ecid){ 
         if (ecid 
!= ""){ 
         var curpg =$("#curpageindex").html();//得到当前页 

                    totalCount = 
Interactive.GetCmdSMSlogCount(&#39;1=1&#39;).value; 
                    userdata = 
Interactive.PageingOpenCmdSMSLog(curpg); 
                    binddata(userdata); 
                    $("#recordcount").html(totalCount);//curpageindex 
                    $("#curpageindex").html(curpg); 
                    if (totalCount % pageSize ==0) 
                    { 
                    $("#pgcount").html(totalCount / pageSize); 
                    }else{ 
                        $("#pgcount").html(parseInt(totalCount / 
pageSize)+1); 
                    } 

                     
                } 

        }
Copy after login
GroupText.aspx.cs: 
private void Page_Load(object sender, System.EventArgs e) 
{ 
// 在此处放置用户代码以初始化页面 
Ajax.Utility.RegisterTypeForAjax(typeof(DataAccess.Interactive)); 
}
Copy after login
Interactive.cs: 
[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)] 
        public DataTable PageingOpenCmdSMSLog(int pgindex,int pageSize) 
        { 
            int pageIndex=pgindex; 
            DataTable 
dt = new DataTable (); 
            JSONHelper json = new JSONHelper(); 
            int count = GetCmdSMSlogCount("1=1"); 
            dt = 
GetDataByPager2000("SendAndRecvData S left join InteractiveSMS I on 
(S.ItemId=I.Id AND S.ECID=I.ECID)","srId","1=1",pageSize,pageIndex,"srId",1, 
                "S.srId,I.ItemName,S.SendMod,S.RecvMod,S.SendDate,S.SendMsg,S.JfValue,S.SendStatus",count); 
            return dt; 
        } 

        [Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)] 
        public int GetCmdSMSlogCount(string where) 
        { 
            try 
            { 
                int count = 
ReturnSQL("select count(*) from SendAndRecvData S left join InteractCommand I 
on(S.ItemId=I.Id AND S.ECID=I.ECID) where "+where); 
                return 
count; 
            } 
            catch (Exception) 
            { 

                throw; 
            } 
        } 
        /// 
<summary> 
        /// 分页获取数据列表 适用于SQL2000 
        /// 
</summary> 
        /// <param name="tablename">表名</param> 
        /// <param name="key">主键</param> 
        /// 
<param name="where">查询条件</param> 
        /// <param 
name="pagesize">每页记录数</param> 
        /// <param 
name="pageindex">页索引</param> 
        /// <param 
name="orderfield">排序字段</param> 
        /// <param 
name="ordertype">排序方式 1=ASC 0=DESC</param> 
        /// <param 
name="fieldlist">查找的字段</param> 
        /// <param 
name="recordcount">总记录数</param> 
        /// 
<returns></returns> 
        public static DataTable 
GetDataByPager2000(string tablename, string key, string where, int pagesize, int 
pageindex, string orderfield, int ordertype, string fieldlist, int recordcount) 
        { 
            string cmd = "ProcCustomPage"; 
            SqlParameter[] para = new SqlParameter[9]; 
            para[0] = new SqlParameter("@Table_Name", tablename); 
            para[1] = new SqlParameter("@Sign_Record", key); 
            para[2] = new SqlParameter("@Filter_Condition", where); 
            para[3] = new SqlParameter("@Page_Size", pagesize); 
            para[4] = new SqlParameter("@Page_Index", pageindex); 
            para[5] = new SqlParameter("@TaxisField", orderfield); 
            para[6] = new SqlParameter("@Taxis_Sign", ordertype); 
            para[7] = new SqlParameter("@Find_RecordList", fieldlist); 
            para[8] = new SqlParameter("@Record_Count", recordcount); 

            return ExecuteDataSet(CommandType.StoredProcedure, cmd, 
para).Tables[0]; 

        } 
        public static DataSet 
ExecuteDataSet(CommandType cmdType, string cmdText, params SqlParameter[] para) 
        { 
            try 
            { 
                using 
(SqlConnection con = new SqlConnection(CONN_STRING)) 
                { 
                    SqlDataAdapter adapter = new SqlDataAdapter(); 

                    using (SqlCommand cmd = new SqlCommand()) 
                    { 
                        DataSet ds = new 
DataSet(); 
                        PrepareCommand(con, cmd, cmdType, 
cmdText, para); 
                        adapter.SelectCommand = cmd; 
                        adapter.Fill(ds); 

                        return ds; 
                    } 
                } 
            } 
            catch(Exception ex) 
            { 
                string d=ex.ToString(); 
                return null; 
            } 
        } 
        /// 
<summary> 
        /// 建立SqlCommand 
        /// </summary> 
        /// <param name="con">SqlConnection 对象</param> 
        /// <param name="cmd">要建立的Command</param> 
        /// <param name="cmdType">CommandType</param> 
        /// <param name="cmdText">执行的SQL语句</param> 
        /// <param name="cmdParms">参数</param> 
        private static void PrepareCommand(SqlConnection con, SqlCommand 
cmd, CommandType cmdType, string cmdText, SqlParameter[] cmdParms) 
        { 
            if (con.State != ConnectionState.Open) 
                con.Open(); 

            cmd.Connection = con; 
            cmd.CommandType = cmdType; 
            cmd.CommandText = 
cmdText; 

            if (cmdParms != null) 
                foreach 
(SqlParameter para in cmdParms) 
                    cmd.Parameters.Add(para); 
        }
Copy after login

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to copy a page in Word How to copy a page in Word Feb 20, 2024 am 10:09 AM

Want to copy a page in Microsoft Word and keep the formatting intact? This is a smart idea because duplicating pages in Word can be a useful time-saving technique when you want to create multiple copies of a specific document layout or format. This guide will walk you through the step-by-step process of copying pages in Word, whether you are creating a template or copying a specific page in a document. These simple instructions are designed to help you easily recreate your page without having to start from scratch. Why copy pages in Microsoft Word? There are several reasons why copying pages in Word is very beneficial: When you have a document with a specific layout or format that you want to copy. Unlike recreating the entire page from scratch

PHP development: How to implement table data sorting and paging functions PHP development: How to implement table data sorting and paging functions Sep 20, 2023 am 11:28 AM

PHP development: How to implement table data sorting and paging functions In web development, processing large amounts of data is a common task. For tables that need to display a large amount of data, it is usually necessary to implement data sorting and paging functions to provide a good user experience and optimize system performance. This article will introduce how to use PHP to implement the sorting and paging functions of table data, and give specific code examples. The sorting function implements the sorting function in the table, allowing users to sort in ascending or descending order according to different fields. The following is an implementation form

How to create custom pagination in CakePHP? How to create custom pagination in CakePHP? Jun 04, 2023 am 08:32 AM

CakePHP is a powerful PHP framework that provides developers with many useful tools and features. One of them is pagination, which helps us divide large amounts of data into several pages, making browsing and manipulation easier. By default, CakePHP provides some basic pagination methods, but sometimes you may need to create some custom pagination methods. This article will show you how to create custom pagination in CakePHP. Step 1: Create a custom pagination class First, we need to create a custom pagination class. this

How to quickly refresh a web page? How to quickly refresh a web page? Feb 18, 2024 pm 01:14 PM

Page refresh is very common in our daily network use. When we visit a web page, we sometimes encounter some problems, such as the web page not loading or displaying abnormally, etc. At this time, we usually choose to refresh the page to solve the problem, so how to refresh the page quickly? Let’s discuss the shortcut keys for page refresh. The page refresh shortcut key is a method to quickly refresh the current web page through keyboard operations. In different operating systems and browsers, the shortcut keys for page refresh may be different. Below we use the common W

How to implement page jump in 3 seconds: PHP Programming Guide How to implement page jump in 3 seconds: PHP Programming Guide Mar 25, 2024 am 10:42 AM

Title: Implementation method of page jump in 3 seconds: PHP Programming Guide In web development, page jump is a common operation. Generally, we use meta tags in HTML or JavaScript methods to jump to pages. However, in some specific cases, we need to perform page jumps on the server side. This article will introduce how to use PHP programming to implement a function that automatically jumps to a specified page within 3 seconds, and will also give specific code examples. The basic principle of page jump using PHP. PHP is a kind of

How to customize and edit standby mode on iPhone: What's new in iOS 17 How to customize and edit standby mode on iPhone: What's new in iOS 17 Sep 21, 2023 pm 04:01 PM

Standby is a new feature in the iOS 17 update that provides a new and enhanced way to access information when your phone is idle quickly. With StandBy, you can conveniently check the time, view upcoming events, browse your calendar, get weather updates for your location, and more. Once activated, the iPhone will intuitively enter standby mode when set to landscape while charging. This feature is perfect for wireless charging points like your bedside table, or when you're away from your iPhone charging during daily tasks. It allows you to swipe through various widgets displayed in standby to access different sets of information from various applications. However, you may want to modify these widgets or even delete some based on your preferences and the information you need frequently. So let's dive into

How to deal with the problem that Laravel page cannot display CSS correctly How to deal with the problem that Laravel page cannot display CSS correctly Mar 10, 2024 am 11:33 AM

"Methods to handle Laravel pages that cannot display CSS correctly, need specific code examples" When using the Laravel framework to develop web applications, sometimes you will encounter the problem that the page cannot display CSS styles correctly, which may cause the page to render abnormal styles. Affect user experience. This article will introduce some methods to deal with the failure of Laravel pages to display CSS correctly, and provide specific code examples to help developers solve this common problem. 1. Check the file path. First check the path of the CSS file.

How to use JavaScript to implement table paging function? How to use JavaScript to implement table paging function? Oct 20, 2023 pm 06:19 PM

How to use JavaScript to implement table paging function? With the development of the Internet, more and more websites use tables to display data. In some cases where the amount of data is large, the data needs to be displayed in pages to improve user experience. This article will introduce how to use JavaScript to implement table paging function and provide specific code examples. 1. HTML structure First, we need to prepare an HTML structure to host tables and paging buttons. We can use &lt;tab

See all articles