Hi all

I have used timer control in datalist in my web application . i bind all fields as below

                     RepeatColumns="5" Width="656px" DataKeyField="id"
                    onitemdatabound="PrdDataList_ItemDataBound">
                   
                       
                           
                               
                                                                                 
                             
                                   
                                   
                                   
                                       
                                   
                                   
                                       

                                   
                                   
                                       
                                   
                                   
                                       
                                   
                               

                                    Auction
                               

                                                                                                style="color:#68b121; font-weight: 700;      font-size: 26px" Text='<%# DataBinder.Eval(Container.DataItem, "TimeDiff")%>'> 
                 
                         
                                                   

                                          
                                          
                                          
                                          
                                            
                                              
                                       

                                           
                                                   
                                              

rs 
                                                     


                                                   

                                           

                                       

                                            Buy Now:
                                            rs
                                             <%#DataBinder.Eval(Container.DataItem,"Price") %>
                                       

                                           
                                               
                                                   
                                               
                                           

                                                       
                                                            
                                                                <%#Eval("UserId") %>
                                                           
                                                               
                                                       

                                                   

                                       

                                           
                                                        
                                                                                                            ImageUrl="~/images/btn_bid.jpg" onclick="btnBid_Click" >        
                                                    <%-- --%>
                                               

                                           

                                       

                           
                       

                       
                   

               
                      



I bind the data list at page load. But the timer start only with the last template created. The 'timeDiff" is exact difference between timer starttime and currentdatetime. The code is here:



        protected void BidTimer_Tick(object sender, EventArgs e)
        {
            PerformClock();
        }
         void PerformClock()
        {
            foreach (DataListItem dlitem in PrdDataList.Items)
            {
                lblid = (Label)dlitem.FindControl("lblid");
                auc_id = Convert.ToInt32(lblid.Text);
                BidTimer = (Timer)dlitem.FindControl("BidTimer");
                mseconds = (HtmlInputHidden)dlitem.FindControl("mseconds");
                second = (HtmlInputHidden)dlitem.FindControl("second");
                minute = (HtmlInputHidden)dlitem.FindControl("minute");
                hour = (HtmlInputHidden)dlitem.FindControl("hour");
                day = (HtmlInputHidden)dlitem.FindControl("day");
                lblTimeWatch = (Label)dlitem.FindControl("lblTimeWatch");
                btnBid = (ImageButton)dlitem.FindControl("btnBid"); 
            }

            MilliSeconds = Convert.ToInt32(mseconds.Value);
            Seconds = Convert.ToInt32(second.Value);
            Minutes = Convert.ToInt32(minute.Value);
            Hours = Convert.ToInt32(hour.Value);
            Days = Convert.ToInt32(day.Value);
            ds = AuctionDAL.retrieveAll();

            if (lblTimeWatch.Text == "01.00:01:00")
            {
                lblTimeWatch.Text = "01.00:00:59:";
                Minutes = 0;
                Hours = 0;
                Seconds = 59;
                Days = 1;
            }
            else if (lblTimeWatch.Text == "01.01:01:00")
            {
                lblTimeWatch.Text = "01.01:00:59";
                Minutes = 0;
                Hours = 1;
                Seconds = 59;
                Days = 1;

            }
            else if (lblTimeWatch.Text == "01.01:00:00")
            {
                lblTimeWatch.Text = "01.00:59:59";
                Days = 1;
                Hours = 0;
                Minutes = 59;
                Seconds = 59;
            }
            else if (lblTimeWatch.Text == "01.00:00:00")
            {
                lblTimeWatch.Text = "00.59:59:59";
                Days = 0;
                Hours = 59;
                Minutes = 59;
                Seconds = 59;
            }


            else if (lblTimeWatch.Text == "00:00:00")
            {
                DataSet dsbid = new DataSet();
                dsbid = BidDAL.retrieveBidData(auc_id);
                if (dsbid.Tables[0].Rows.Count > 0)
                {

                    Seconds--;
                    if (Seconds == -1)
                    {
                        lblTimeWatch.Text = "Go1";
                    }

                }
                else
                {

                    lblTimeWatch.Text = "00:00:15";
                    Seconds = 15;
                    Minutes = 0;
                    Hours = 0;
                    MilliSeconds = 0;

                }



            }
            else if (lblTimeWatch.Text == "Go1")
            {
                Seconds--;
                if (Seconds == -2)
                {
                    lblTimeWatch.Text = "Go2";
                }

            }
            else if (lblTimeWatch.Text == "Go2")
            {
                Seconds--;
                if (Seconds == -3)
                {
                    lblTimeWatch.Text = "Go3";
                }
            }
            else if (lblTimeWatch.Text == "Go3")
            {
                Seconds--;
                if (Seconds == -4)
                {
                    BidTimer.Enabled = false;
                    lblTimeWatch.Text = "Sold";

                    //btnBid.Text= "BidEnd";
                    btnBid.Enabled = false;
                }
            }
            else if (lblTimeWatch.Text == "00:00:15")
            {
                Seconds--;
                Minutes = 0;
                Hours = 0;
                MilliSeconds = 0;

            }
            else if (lblTimeWatch.Text == "00:01:00")
            {
                Minutes = 0;
                MilliSeconds = 0;
                Seconds = 59;
                Hours = 0;
            }

            else
            {
                if (Seconds % 60 == 0)
                {
                    Minutes--;
                    MilliSeconds = 0;
                    Seconds = 59;


                    if (Minutes % 3600 == 0)
                    {
                        Hours--;
                        MilliSeconds = 0;
                        Seconds = 59;
                        Minutes = 59;

                        if (Hours % 86400 == 0)
                        {
                            Days--;
                            Hours = 23;
                            MilliSeconds = 0;
                            Seconds = 59;
                            Minutes = 59;

                        }
                    }
                }
                Seconds--;


            }


            mseconds.Value = MilliSeconds.ToString();
            second.Value = Seconds.ToString();
            minute.Value = Minutes.ToString();
            hour.Value = Hours.ToString();
            day.Value = Days.ToString();

            if (Days > 0)
            {
                lblTimeWatch.Text = Days.ToString("00") + "." + Hours.ToString("00") + ":" + Minutes.ToString("00") + ":" + Seconds.ToString("00");
            }
            else
            {
                if (Seconds >= 0)
                {
                    lblTimeWatch.Text = Hours.ToString("00") + ":" + Minutes.ToString("00") + ":" + Seconds.ToString("00");
                }
            }


        }


Please help me so that i can successfully use timer in my web application.


for like website click here http://www.BidRivals.com