0

I have a listview that I want to update every 5 seconds or so, the update panel does refresh but to no effect.

<asp:Timer runat="server" ID="UP_Timer" Interval="5000" />

<asp:UpdatePanel runat="server" ID="Proc_UpdatePanel">
    <ContentTemplate>
        <asp:ListView ID="ListView1" runat="server"
            DataKeyNames="procName"
            ItemType="SerMon.RemoteProcess" SelectMethod="fetchFromQueue">
            <EmptyDataTemplate>
                <table>
                    <tr>
                        <td>No data was returned.</td>
                    </tr>
                </table>
            </EmptyDataTemplate>
            <EmptyItemTemplate>
                <td />
            </EmptyItemTemplate>
            <LayoutTemplate>
                <table runat="server" id="table1" class="table table-striped table-hover ">
                    <thead>
                        <tr runat="server">
                            <th>#</th>
                            <th>Process</th>
                            <th>Status</th>
                            <th>Machine</th>
                        </tr>
                        <tr id="itemPlaceholder" runat="server"></tr>
                    </thead>
                </table>
            </LayoutTemplate>
            <ItemTemplate>
                <tr runat="server">
                    <td>1</td>
                    <td>
                        <asp:Label runat="server" ID="lblId"><%#: Item.ProcName%></asp:Label></td>
                    <td>
                        <asp:Label runat="server" ID="Label1"><%#: Item.Procstatus%></asp:Label></td>
                    <td>
                        <asp:Label runat="server" ID="Label2"><%#: Item.mcName%></asp:Label></td>
                </tr>
            </ItemTemplate>
        </asp:ListView>
    </ContentTemplate>
</asp:UpdatePanel>

The whole page refreshes, yet the method to be called for populating the listview is not called. Where am I going wrong?

VDWWD
  • 35,079
  • 22
  • 62
  • 79
NeuralLynx
  • 197
  • 1
  • 2
  • 14

1 Answers1

0

There are 2 different issues here.

First of all the Timer is outside the UpdatePanel, so of course it will do a full PostBack. Move the timer inside the UpdatePanel.

Second, you did not specify an OnTick event for the timer. Without it the Timer will just refresh the page.

<asp:UpdatePanel runat="server" ID="Proc_UpdatePanel">
    <ContentTemplate>
        <asp:Timer runat="server" ID="UP_Timer" Interval="5000" OnTick="UP_Timer_Tick" />
    </ContentTemplate>
</asp:UpdatePanel>

Code behind:

protected void UP_Timer_Tick(object sender, EventArgs e)
{
    //update the ListView
}
VDWWD
  • 35,079
  • 22
  • 62
  • 79