当前位置:编程学习 > C#/ASP.NET >>

怎么样实现GRIDVIEW无刷新翻页!~~~

哪个高手给点方法!~ --------------------编程问答-------------------- ajax --------------------编程问答-------------------- UpdatePanel --------------------编程问答-------------------- 或者直接用第三方控件,呵呵

http://bbs.szblogs.com/showtopic-182.html --------------------编程问答-------------------- asp.net ajax updatepannel --------------------编程问答-------------------- 最现实的方法  UpdatePanel

AJAX技术 和数据控件没有完美的一个结合方式

特别是gridview  一般做AJAX都不用这个的 --------------------编程问答-------------------- gridview  做AJAX 能做一个AJAX删除功能 --------------------编程问答--------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
留言版
</title><link href="images/css.css" rel="Stylesheet" type="text/css" />

    <script language="javascript" type="text/javascript">
        function seedmsg()
        {//发送信息
            var qq = document.getElementById('QQ');
            var Email = document.getElementById('Email');
            var name = document.getElementById('name');
            var title = document.getElementById('title');
            var text = document.getElementById('text');
            document.getElementById('tem').style.display = "inline";
            Message.strmessageseed(qq.value,Email.value,name.value,title.value,text.value,is_backcall);
        }
        function is_backcall(res)
        {//返回值判断是否成功
            var bRet = res.value;
            if(bRet == 0)
            {
                setTimeout("loadmessage(1)",0);
                document.getElementById('QQ').value="";
                document.getElementById('Email').value="";
                document.getElementById('name').value="";
                document.getElementById('title').value="";
                document.getElementById('text').value="";
                document.getElementById('tem').style.display = "none";
            }
            else if(bRet == 1)
            {

            }            
        }
        var PerPage = 5;//定义每页显示数目
        function loadmessage(PageNumber)
        {
            document.getElementById('tem').style.display = "inline";
            Message.PageList1(PerPage,PageNumber,islist_backcall);
        }
        function islist_backcall(res)
        {
            var ds = res.value;
            var strHtml;
            //取得表的行数
            var iLen = ds.Tables[0].Rows.length;
            var strHtml = "<div align='left'>";
            if(iLen != 0)
            {
                //循环遍历表的每一行构造table
                for(i=0;i<iLen;i++)
                {//ds.Tables[0].Rows[i].letter_time.toLocaleString()
                     //构造显示数据的table 且表头 
                    strHtml += "<table style='width: 500px;'>";
                    strHtml += "<tr><td bgColor=#e8edf4>标题:"+ds.Tables[0].Rows[i].title+"</td></tr>";
                    strHtml += "<tr><td bgColor=#efefef>QQ:"+ds.Tables[0].Rows[i].QQ+"   Email:"+ds.Tables[0].Rows[i].Email+"</td></tr>";
                    strHtml += "<tr><td bgColor=#efefef>作者:"+ds.Tables[0].Rows[i].name+"   留言时间:"+ds.Tables[0].Rows[i].datatime.toLocaleString()+"</td></tr>";
                    strHtml += "<tr><td bgColor=#efefef><a id='chakan' align='center' style='cursor:hand;color:red' onclick='displayall();'>查看内容</a><br/><div id='all' style='display:none'>"+ds.Tables[0].Rows[i].content+"</div></td></tr>";
                    strHtml += "</table>";
                }
                strHtml += "</div>";
            }            
            document.getElementById('content').innerHTML = strHtml;
            setTimeout("CurrentPageCount()",0);
        }
         function CurrentPageCount()
        {//获取记录总数
            Message.InitPageListCount(1,Is_CurrentPageBackCall);
        }
        function Is_CurrentPageBackCall(res)
        {
            var iLen = res.value;//记录总数
            var strHtml="总共"+iLen+"条留言信息!<br/>";
            for(i=1;i<iLen/PerPage+1;i++)
            {                
                strHtml += "<a href='javascript:loadmessage("+i+")'>["+i+"]</a>"; 
            }
            document.getElementById('pagecount').innerHTML = strHtml;
            document.getElementById('tem').style.display = "none";
         
        }
        function displaymsg()
        {
            var msg = document.getElementById('seedmsg');
            if(msg.style.display == "none")
            {
                msg.style.display = "inline";
            }
            else if(msg.style.display == "inline")
            {
                msg.style.display = "none";
            }
        }
        function displayall()
        {
            var all =document.getElementById('all');
            var chakan = document.getElementById('chakan');
            chakan.innerText = "关闭内容";
            if(all.style.display == "none")
            {
                all.style.display = "inline";
                chakan.innerText="关闭内容";
            }
            else if(all.style.display == "inline")
            {
                all.style.display = "none";
                chakan.innerText="查看内容";
            }
        }
    </script>

</head>
<body onload="loadmessage(1);">
    <form name="form1" method="post" action="Message.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE0MDkxNzYwNDNkZFyTVQxyuISjx+jfrfMx7s/hY+EQ" />
</div>


<script type="text/javascript" src="/ajaxpro/core.ashx"></script>
<script type="text/javascript" src="/ajaxpro/Message,App_Web_urxmute8.ashx"></script>

    <div align="center">
    <table style='width: 500px;'>
    <tr>
                    <td align="center">
            <table style='width: 500px;'>
                <tr>
                    <td>
                        <div id="content">
                            主要显示内容</div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <div id="pagecount">
                            分页按钮</div>
                    </td>
                </tr>
            </table>
            </td>
            </tr>
            <tr>
            <td align="left">
            <div align="center"><a onclick="displaymsg();" style="cursor:hand">=== 给我留言 ===</a></div>
            <div id="seedmsg" style="display:none">
                <table style='width: 500px;'>
                    <tr>
                        <td>
                        QQ:  
                    <input id="QQ" type="text" style="width: 450px" class="textbox" maxlength="50" />
                        </td>
                    </tr>
                    <tr>
                        <td> Email:<input id="Email" type="text" style="width: 450px" class="textbox" maxlength="50" />
                        </td>
                    </tr>
                    <tr>
                        <td>  作 者:<input id="name" type="text" style="width: 450px" class="textbox" maxlength="50" />
                        </td>
                    </tr>
                    <tr>
                        <td>  标 题:<input id="title" type="text" style="width: 450px" class="textbox" maxlength="255" />
                        </td>
                    </tr>
                    <tr>
                        <td> 内 容:<textarea id="text" cols="20" rows="2" style="width: 450px; height: 150px" class="textbox"></textarea>
                        </td>
                    </tr>
                     <tr>
                        <td align="center"> <input id="Button1" type="button" onclick="seedmsg()" value="  发送留言  " />
                        </td>
                    </tr>
                </table>
                </div>
            </td>
        </tr>
        </table>
        <p id="tem" align="center" style="display:none;position:absolute;top:50%;left:50%;margin:-100px 0 0 -100px;width:200px;height:200px;">
            <img src="images/load.gif" /></p>
            </div>
    </form>
</body>
</html>


这是我用ajaxpro框架做着玩的留言版 参考下 --------------------编程问答-------------------- 在換頁的時候,對Gridview重新綁定沒有? --------------------编程问答-------------------- updatepanel 满足你的一切无刷新要求
--------------------编程问答-------------------- UpdatePanel 就ok了吧.... --------------------编程问答-------------------- UpdatePanel 

AJAX
--------------------编程问答-------------------- 如果楼主采用的是一次把数据全取出的绑定方式的话,可以设置GridView的EnableSortingAndPagingCallbacks 属性,就可以了。
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,