2017-02-27 6 views
0

5 초마다 업데이트하려는 목록보기가 있습니다. 업데이트 패널은 새로 고치지 만 아무 효과가 없습니다.UpdatePanel을 사용하여 asp : webform에서 ListView 새로 고침

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

전체 페이지가 새로 고쳐 지지만 listview를 채우는 데 호출 할 메소드는 호출되지 않습니다. 내가 어디로 잘못 가고 있니?

+0

볼이

답변

0

여기에는 두 가지 문제가 있습니다.

우선 TimerUpdatePanel 외부에 있으므로 물론 전체 포스트 백을 수행 할 것입니다. 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 
}