i have a gridview with a column of checkboxes. the check_all function work well but when i insert tablesorter to sort my gridview, the check_all function cant work.
below is my code:

<title></title>
    <script src="Scripts/jquery-latest.js" type="text/javascript"></script>
    <script src="Scripts/jquery.tablesorter.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#gvMsg").tablesorter()
        });
</script>

<script type="text/javascript">
    $("#check_all").live("click", function (event) {
        if ($("#check_all").hasClass('not_checked')) {
            $("#check_all").removeClass('not_checked');
            $(".check-box").attr('checked', true);
        }
        else {
            $("#check_all").addClass('not_checked');
            $(".check-box").attr('checked', false);
        }
    });
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:GridView ID="gvMsg" runat="server" AutoGenerateColumns="False" 
            CellPadding="4" ForeColor="#333333" GridLines="None" 
            onprerender="gvMsg_PreRender">
            <AlternatingRowStyle BackColor="White" />
            <Columns>
            <asp:TemplateField >
            <HeaderTemplate>
                <th id="th1" align="left" style="width:10px" runat="server"><input type="checkbox" class="check-box not_checked" id="check_all"/></th>
                <th id="th2" align="left" style="width:200px" runat="server">From</th>
                <th id="th3" align="left" style="width:500px" runat="server">Subject</th>
                <th id="th4" align="left" style="width:150px" runat="server">Date</th>
            </HeaderTemplate>
            <ItemTemplate>
                <td><input type="checkbox" class="check-box" id="check_box"><asp:Label ID="lblDel" runat="server" Text='<%# Eval("eid") %>' Visible="false" /></td>     
                <td><asp:Label ID="lblFrom" runat="server" Text='<%# Eval("From") %>' /></td>
                <td><asp:LinkButton ID="cmdSel" runat="server"Text='<%# Eval("Subject") %>' /><br /></td>
                <td><asp:Label ID="lblDate" runat="server" Text='<%# Eval("Date") %>' /></td>
            </ItemTemplate>
            </asp:TemplateField>
                
            </Columns>
            <EditRowStyle BackColor="#2461BF" />
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#EFF3FB" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#F5F7FB" />
            <SortedAscendingHeaderStyle BackColor="#6D95E1" />
            <SortedDescendingCellStyle BackColor="#E9EBEF" />
            <SortedDescendingHeaderStyle BackColor="#4870BE" />
        </asp:GridView>
    
    </div>
    </form>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.