Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用UpdatePanel刷新asp:webform中的ListView_C#_Asp.net_Listview_Webforms_Updatepanel - Fatal编程技术网

C# 使用UpdatePanel刷新asp:webform中的ListView

C# 使用UpdatePanel刷新asp:webform中的ListView,c#,asp.net,listview,webforms,updatepanel,C#,Asp.net,Listview,Webforms,Updatepanel,我有一个列表视图,我想每5秒左右更新一次,更新面板会刷新,但没有效果 <asp:Timer runat="server" ID="UP_Timer" Interval="5000" /> <asp:UpdatePanel runat="server" ID="Proc_UpdatePanel"> <ContentTemplate> <asp:ListView ID="ListView1" runat="server"

我有一个列表视图,我想每5秒左右更新一次,更新面板会刷新,但没有效果

<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>

没有返回任何数据。
#
过程
地位
机器
1.

整个页面将刷新,但没有调用用于填充listview的方法。我哪里出错了?

这里有两个不同的问题

首先,
计时器
更新面板
之外,因此它当然会进行完整的回发。在UpdatePanel中移动计时器

其次,您没有为计时器指定
OnTick
事件。没有它,计时器只会刷新页面

<asp:UpdatePanel runat="server" ID="Proc_UpdatePanel">
    <ContentTemplate>
        <asp:Timer runat="server" ID="UP_Timer" Interval="5000" OnTick="UP_Timer_Tick" />
    </ContentTemplate>
</asp:UpdatePanel>
看到这个了吗
protected void UP_Timer_Tick(object sender, EventArgs e)
{
    //update the ListView
}