无法获取更新面板以更新datalist

时间:2014-04-14 11:06:49

标签: asp.net timer updatepanel

我有以下代码,并尝试将计时器放在更新面板的内部和外部,但数据列表不会更新:

            ContentTemplate>
                 <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick"></asp:Timer>
                <asp:DataList ID="DataList3" runat="server" BorderColor="Gray" BorderWidth="0px" DataSourceID="SqlDataSource2" Font-Bold="False" Font-Italic="False" Font-Names="Calibri Light" Font-Overline="False" Font-Size="Small" Font-Strikeout="False" Font-Underline="False" GridLines="Horizontal" Width="441px">
                    <ItemTemplate>
                        &nbsp;<asp:Label ID="DateLabel" runat="server" Text='<%# Eval("Date", "{0:d}") %>' />
                <br />
                        Epic/Sector:
                        <asp:Label ID="EpicLabel" runat="server" Text='<%# Eval("Epic") %>' />
                <br />
                        Company:
                        <asp:Label ID="CompanyLabel" runat="server" Text='<%# Eval("Company") %>' />
                <br />
                        News:
                        <asp:Label ID="NewsLabel" runat="server" Text='<%# Eval("News") %>' />
                <br />
                <br />
                    </ItemTemplate>
                    <SeparatorStyle BackColor="Aqua" Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" ForeColor="Gray" HorizontalAlign="Left" />
                </asp:DataList>
            </ContentTemplate>
        </asp:UpdatePanel>

请求帮助,谢谢

1 个答案:

答案 0 :(得分:0)

<asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="5000"></asp:Timer>
 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:DataList ID="DataList1" runat="server"></asp:DataList>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
    </Triggers>
</asp:UpdatePanel>