jQuery DataTable plugin not working after ASP.Net UpdatePanel PostBack

suhradam.ankit
 
on Dec 23, 2014 03:01 AM
13298 Views

i add timer in my repeater control it perfactly run .but when execute timer then output loast repeater control designing.

how to solve it?

 

 

<link rel="Stylesheet" type="text/css" href="css/demos.css" />
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/jquery.dataTables.js"></script>
    <script type="text/javascript">
        $(function () {
            $('.dataTable').dataTable();
        });
    </script>

 

<div class="grid_10">
        <div class="box round">
            <h2>Home</h2>               
            <div style="text-align:center">
                <asp:Label ID="lblMessage" runat="server" class="error"></asp:Label>
            </div>   
            <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:Timer runat="server" ID="Timer1" Interval="60000" OnTick="Timer1_Tick" />
            <asp:Repeater ID="List" runat="server" OnItemCommand="List_ItemCommand">
                <HeaderTemplate>
                    <table class="data display dataTable" id="tab">
                        <thead>
                            <tr>
                                <th>Name</th>
                                <th>Time At</th>
                            </tr>
                        </thead>
                        <tbody>
                </HeaderTemplate>
                <ItemTemplate>
                            <tr>
                                <td><%#Eval("Name")%></td>
                                <td><%#Eval("Time")%> Minutes</td>
                            </tr>                                
                </ItemTemplate>
                
                <FooterTemplate>                            
                       </tbody> </table><br /><br /><br />
                </FooterTemplate>
            </asp:Repeater>
            

            <div class="box round">  
                <table style="float: right;text-align: right;font-size:15px">
                    <tr>
                        <td>
                        Record Size:
                            <asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="true" OnSelectedIndexChanged="PageSize_Changed">
                                <asp:ListItem Text="10" Value="10" />
                                <asp:ListItem Text="25" Value="25" />
                                <asp:ListItem Text="50" Value="50" />
                            </asp:DropDownList>

                        <asp:Repeater ID="rptPager" runat="server">
                            <ItemTemplate>
                                <asp:LinkButton ID="lnkPage" runat="server" Text = '<%#Eval("Text") %>' CommandArgument = '<%# Eval("Value") %>' Enabled = '<%# Eval("Enabled") %>' OnClick = "Page_Changed"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:Repeater>
                        </td>
                    </tr>
                </table> 
            </div> 
		</ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
    </Triggers>
</asp:UpdatePanel>           
        </div>
    </div>
    <div class="clear">
    </div>

 

protected void Timer1_Tick(object sender, EventArgs e)
        {
            objBussinessObj.PageIndex = 1;
            objBussinessObj.PageSize = 10;
            CurrentLocationList.DataSource = objBussinessLogic.GetAllDetails(objBussinessObj);
            CurrentLocationList.DataBind();
        }

private void GetDetails(int pageIndex)
        {
            objBussinessObj.PageIndex = pageIndex;
            objBussinessObj.PageSize = int.Parse(ddlPageSize.SelectedValue);
            CurrentLocationList.DataSource = objBussinessLogic.GetDetails(objBussinessObj);
            CurrentLocationList.DataBind();
            int recordCount = Convert.ToInt16(objBussinessObj.RecordCount.ToString());
            this.PopulatePager(recordCount, pageIndex);
        }

        protected void Page_Changed(object sender, EventArgs e)
        {
            int pageIndex = int.Parse((sender as LinkButton).CommandArgument);
            this.GetDetails(pageIndex);
        }

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
Mudassar
 
on Dec 23, 2014 03:02 AM

That's because your plugin is not applied after Partial Postback and hence please refer

jQuery Plugins not working after ASP.Net AJAX UpdatePanel Partial PostBack or when Asynchronous request is over