日期:2014-05-17  浏览次数:20388 次

jquery ajax 异步刷新gridview的问题
这是前台代码
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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 runat="server">
    <title></title>
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript">
    function UpdateGrid(args) 
    {
        args = args + "$" + window.document.getElementById('ddl').value;
        <%= ClientScript.GetCallbackEventReference(this,"args", "ShowResult", null) %>
    } 
    function ShowResult(eventArgument,context)
    {
        window.document.getElementById('Gridview').innerHTML = eventArgument;
    }
    $(function(){
        $("#button1").click(
            function(){
            $.ajax({
                 type:'POST',
                 url:'Default.aspx',
                 data:{action:'action'},
                 success: savesuccesscallbace
            })
            }
            )
            });
     //保存成功后的回调函数
    function savesuccesscallbace(r)
    {
        
    }
    </script>
    
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h3>Test Async Gridview</h3>
        <hr />
    </div>
    <input id="input1" type="text"/>
    <input type="button" id="button1" value="提交"/>
    <div id="Gridview">
        <asp:GridView EnableViewState="false" runat="server" id="_grid" OnRowDataBound="_grid_RowDataBound" AllowPaging="True" ></asp:GridView>
        <br/>
    </div> Change page length to — 
    <asp:DropDownList ID="ddl" runat="server