Multiple Timers in each row of gridview (countdown effect)

Last post 03-06-2008 4:37 AM by Jin-Yu Yin - MSFT. 2 replies.

Sort Posts:

  • Multiple Timers in each row of gridview (countdown effect)

    02-29-2008, 1:57 PM
    • Loading...
    • echavez
    • Joined on 11-21-2006, 10:45 PM
    • Posts 3

    Hi,

     i am trying to have a gridview and in one of the columns to a countdown using an updatepanel, timer and a simple function that does a simple timespan of a value passing thru the gridview

     i can get it work but how can i get each gridrow to show its own unique countdown, because right it keeps over writing to one

     HELP!!!

    I am pasting the code below

    <asp:GridView ID="myGV" runat="server" AutoGenerateColumns="false">

    <Columns>

    <asp:TemplateField HeaderText="Countdown">

    <ItemTemplate>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">

    <ContentTemplate>

    <asp:Label ID="lblTime" runat="server" Text='<%#Eval("Value") %>' Visible="false" />

    <%=CountDown(lblTime.Text)%>

    <asp:Timer Interval="1000" ID="timer1" runat="server" />

    </ContentTemplate>

    <Triggers>

    <asp:AsyncPostBackTrigger ControlID="timer1" EventName="Tick" />

    </Triggers>

    </asp:UpdatePanel>

    </ItemTemplate>

    </asp:TemplateField>

    <asp:BoundField DataField="Value" HeaderText="Passing Value" />

    </Columns>

    </asp:GridView>

     

    Public Function CountDown(ByVal DueDate As String) As String

    Dim dLast As DateTime = CDate(DueDate)

    Dim dNow As DateTime = Now

    Dim iTime As TimeSpan = dLast.Subtract(dNow)

    Return Format(iTime.TotalHours, "00") & ":" & Format(iTime.Minutes, "00") & ":" & Format(iTime.Seconds, "00")

    End Function

  • Re: Multiple Timers in each row of gridview (countdown effect)

    03-02-2008, 11:13 AM
    Answer

    My question is why aren't you putting the update panel around the hold gridview?

    Cheers
    Al
    My Blog
    GeoTwitter.NET
    Please click on 'Mark as Answer' if this post answered your question!
  • Re: Multiple Timers in each row of gridview (countdown effect)

    03-06-2008, 4:37 AM
    Answer

    Hi,

    Thank you for your post!

    I think you can do it by just using one updatepanel and one timer.

    You should call  CountDown(lblTime.Text) in GridView.RowDataBound event.

    http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx

    Best Regards, 

     

    Sincerely,
    Jin-Yu Yin
    Microsoft Online Community Support
Page 1 of 1 (3 items)
Microsoft Communities
Page view counter