I wrote a code at page load in which i fetch the countdown start time from database. now i find the difference between start time and current time.(countdown time which will ends to zero).
After that i insert that time difference as a string along with id.
Then i fetch the time difference from database in a data list label.
Every time the page refresh time difference vary in different browsers and in the same browser.
If anyone have solution for above please tell me.
Thanx in advance
Code is here
.aspx.cs
pageload
m_ds = indexDAL.getcontent();
if (m_ds.Tables[0].Rows.Count > 0)
{
for (int m = 0; m < m_ds.Tables[0].Rows.Count; m++)
{
auc_id = Convert.ToInt64(m_ds.Tables[0].Rows[m]["id"].ToString());
string aid = m_ds.Tables[0].Rows[m]["id"].ToString();
startingtime = Convert.ToDateTime(m_ds.Tables[0].Rows[m]["StartDateTime"].ToString());
System.TimeSpan result = startingtime.Subtract(DateTime.Now);
string time123 = result.Hours.ToString() + ":" + result.Minutes.ToString() + ":" + result.Seconds.ToString();
if (result.TotalSeconds >= 0)
{
int x = indexDAL.InsertStartTime(auc_id, time123);
}
}
}
if (!Page.IsPostBack)
{
if (ProductCatid != 0)
{
ds1 = indexDAL.getcontentproductcatwise(ProductCatid);
PrdDataList.DataSource = ds1;
PrdDataList.DataBind();
}
else
{
ds1 = indexDAL.getcontent1();
PrdDataList.DataSource = ds1;
PrdDataList.DataBind();
}
}
.aspx
RepeatColumns="5" DataKeyField="id"
onitemdatabound="PrdDataList_ItemDataBound"
onitemcommand="PrdDataList_ItemCommand" >
Auction | ||||||||||
|
database queries
m_ds = indexDAL.getcontent();
Select a.AuctionId as id,a.ProductCode,p.ProductName,p.categoryId,p.Price,p.ImageNm,a.AuctionTitle,a.StartDateTime,a.ClosedDateTime,a.BidUsed
from Tbl_auction a inner join Tbl_product p on a.ProductCode=p.ProductCode where a.AuctionStatus='Coming soon' and a.IsActive='1' and p.IsActive='1'
indexDAL.InsertStartTime(auc_id, time123);
if not exists(select * from AuctionTime where AuctionId=@id)
insert into AuctionTime (AuctionId,TimeDiff) Values(@id,@difft)
else
update AuctionTime set TimeDiff=@difft where AuctionId=@id
ds1
SELECT a.AuctionId AS id, a.ProductCode, p.ProductName, p.CategoryId, p.Price,a.CurrentProductPrice, p.ImageNm, a.AuctionTitle, a.StartDateTime, a.ClosedDateTime, a.BidUsed,
dbo.AuctionTime.TimeDiff
FROM dbo.Tbl_Auction AS a INNER JOIN
dbo.Tbl_Product AS p ON a.ProductCode = p.ProductCode INNER JOIN
dbo.AuctionTime ON a.AuctionId = dbo.AuctionTime.AuctionId where a.AuctionStatus='Coming soon' and p.IsActive='1' and a.IsActive='1'

Replies
Know the answer? Post it — somebody with the same question will find it here.