I have a GridView with EnableSortingAndPagingCallbacks enabled. When the user clicks to change pages, a callback is performed and the GridView is updated. I need to run a JavaScript function immediately after this happens so I can perform some client-side actions on the new page of data. How can I accomplish this?
The closest I've found to my question is this: How to have a javascript callback executed after an update panel postback?. However, using the pageLoad() function won't work here because pageLoad() doesn't seem to be triggered after a GridView callback.
I need to have this work with IE7, or otherwise I'd use the DOMSubtreeModified event listener.
Sample code where GridView1_PageIndexChanging and pageLoad won't fire.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test_script.aspx.cs" Inherits="test_script" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<form id="form1" runat="server">
    <asp:ToolkitScriptManager ID="ScriptManager1" runat="server" ScriptMode="Release" />
    <asp:GridView ID="GridView1" runat="server" AllowPaging="true" 
        EnableSortingAndPagingCallbacks="true" DataSourceID="SqlDataSource1" 
        OnPageIndexChanging="GridView1_PageIndexChanging" />
</form>
<script type="text/javascript">
    function pageLoad(sender, args) {
        alert('pageLoad');
    }
</script>
Code behind:
public partial class test_script : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        // This doesn't fire when EnableSortingAndPagingCallbacks is set to true
    }
}
In the above code, pageLoad() fires when the page is first loaded but it does not fire after the GridView is paged. In the code behind, Page_Load fires when the GridView is paged but GridView1_PageIndexChanging() does not.
If I change EnableSortingAndPagingCallbacks to false, all functions fire as you would expect on each GridView page change.
 
     
     
    