如何在ASP.NET中的Onclick事件后重新加载数据表

时间:2018-02-07 16:20:19

标签: javascript jquery asp.net datatable

我使用数据表来显示表格,但是在点击按钮以从服务器过滤数据后,我的数据表没有重新加载。我正在使用GridView webform。

<script>
$(function () {
    $("#ctl00_ContentPlaceHolderMain_gvProductionList").prepend($("<thead></thead>").append($(this).find("tr:first"))).dataTable({
        "bProcessing": true,
        "bStateSave": true,
        "bJQueryUI": true
    });
});
</script>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
    <asp:CheckBox ID="cbProduction" runat="server" AutoPostBack="True"
        OnCheckedChanged="cbProduction_CheckedChanged"
        Text="Show Production Batches [True / False]" />
    <asp:Label ID="Label1" runat="server" Text="StartDate:"></asp:Label>
    <asp:TextBox ID="dtFrom" runat="server"></asp:TextBox>
    <asp:CalendarExtender ID="dtFrom_CalendarExtender" runat="server"
        Enabled="True" TargetControlID="dtFrom" Format="dd-MMM-yyyy">
    </asp:CalendarExtender>
    <asp:Label ID="Label2" runat="server" Text="EndDate: "></asp:Label>
    <asp:TextBox ID="dtTo" runat="server"></asp:TextBox>
    <asp:CalendarExtender ID="dtTo_CalendarExtender" runat="server" Enabled="True"
        TargetControlID="dtTo" Format="dd-MMM-yyyy">
    </asp:CalendarExtender>
    <asp:Button ID="btnRefresh" runat="server" OnClick="btnRefresh_Click"
        Text="Refresh" />


    <asp:GridView ID="gvProductionList" runat="server" CellPadding="4"
        ForeColor="#333333" GridLines="None"
        OnPageIndexChanged="gvProductionList_PageIndexChanged"
        OnSelectedIndexChanged="gvProductionList_SelectedIndexChanged"
        Width="100%" AllowPaging="True" DataSourceID="srcProductionList"
        AutoGenerateColumns="False">

        <RowStyle CssClass="gridRowStyle" />

        <Columns>
            <asp:CommandField ButtonType="Button" SelectText="Toggle"
                ShowSelectButton="True" />
            <asp:BoundField DataField="WORKORDER_ID" HeaderText="WorkOrder ID">
                <HeaderStyle HorizontalAlign="Left" />
            </asp:BoundField>
            <asp:BoundField DataField="BATCHID" HeaderText="Batch ID">
                <HeaderStyle HorizontalAlign="Left" />
            </asp:BoundField>
            <asp:BoundField DataField="CREATION_DATE" HeaderText="Creation Date">
                <HeaderStyle HorizontalAlign="Left" />
            </asp:BoundField>
            <asp:BoundField DataField="MES_IMPORT_DATE" HeaderText="MES Import Date">
                <HeaderStyle HorizontalAlign="Left" />
            </asp:BoundField>
            <asp:BoundField DataField="MES_IMPORT_STATUS" HeaderText="MES Import Status">
                <HeaderStyle HorizontalAlign="Left" />
            </asp:BoundField>
            <asp:BoundField DataField="ORACLE_ID" HeaderText="Oracle ID">
                <HeaderStyle HorizontalAlign="Left" />
            </asp:BoundField>
        </Columns>

        <FooterStyle CssClass="gridFooterStyle" />
        <PagerStyle CssClass="gridPagerStyle" />
        <SelectedRowStyle CssClass="SelectedRowStyle" />
        <HeaderStyle CssClass="gridHeaderStyle" />
        <EditRowStyle CssClass="gridEditRowStyle" />
        <AlternatingRowStyle CssClass="gridAlternatingRowStyle" />
    </asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>

页面使用DataTable加载表,但重新加载后选择日期开始,日期结束和刷新数据表未加载

0 个答案:

没有答案