timer control for data list

Last post 11-13-2009 4:09 AM by Vince Xu - MSFT. 3 replies.

Sort Posts:

  • timer control for data list

    11-11-2009, 4:25 AM
    • Member
      4 point Member
    • crosswinds
    • Member since 11-06-2009, 4:42 AM
    • Posts 4

    i want to retrieve the data using data list control from a data base at regular time interval say for eg 1 min.


  • Re: timer control for data list

    11-11-2009, 5:47 AM
    Answer
    • Star
      13,860 point Star
    • kipo
    • Member since 07-20-2006, 7:10 AM
    • Croatia
    • Posts 2,374

    Controls:

            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick">
                    </asp:Timer>
                    <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="NorthWindDataContext"
                        EnableDelete="True" EnableInsert="True" EnableUpdate="True" TableName="Products">
                    </asp:LinqDataSource>
                    <asp:DataList ID="DataList1" runat="server" DataSourceID="LinqDataSource1">
                    </asp:DataList>
                </ContentTemplate>
            </asp:UpdatePanel>


    Code:

        protected void Timer1_Tick(object sender, EventArgs e)
        {
            DataList1.DataBind();
        }


     

  • Re: timer control for data list

    11-11-2009, 10:01 PM
    Answer

    Set the Interval property to specify how often postbacks will occur, and set the Enabled property to turn the Timer on or off. The Interval property is defined in milliseconds and has a default value of 60,000 milliseconds, or 60 seconds.

    When a postback was initiated by the Timer control, the Timer control raises the Tick event on the server. You can create an event handler for the Tick event to perform actions when the page is posted to the server. In this event you can bind the data to DataList

    http://www.asp.net/AJAX/Documentation/Live/overview/UsingTimerControlTutorial.aspx 

    Chetan Sarode
    Software Engineer,
    Approva Systems Pvt Ltd,
    Pune, India.
  • Re: timer control for data list

    11-13-2009, 4:09 AM
    Answer

    You can put the Ajax Timer control and DataList control into an updatepanel. You can set interval of timer to 1min or 2min.

    Suggestion: To improve the performance of the page, I suggest you had better set interval to 3 or 5 min.


    Vince Xu
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Page 1 of 1 (4 items)