TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Arpit gupta
NA
5
19.8k
Problem regarding data save and retrieve at page load
Sep 7 2010 7:59 AM
Hi all
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
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DataList ID="PrdDataList" runat="server" RepeatDirection="Horizontal"
RepeatColumns="5" DataKeyField="id"
onitemdatabound="PrdDataList_ItemDataBound"
onitemcommand="PrdDataList_ItemCommand" >
<ItemTemplate>
<table border="0" cellspacing="0" cellpadding="0" class="box2">
<tr>
<td class="hd">
<asp:label ID="lblPrdCode" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ProductCode")%>' Visible="false"></asp:label>
<span>Auction</span><asp:label ID="lblid" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "id")%>'></asp:label>
</td>
</tr>
<tr>
<td class="bg">
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td><h2><%# DataBinder.Eval(Container.DataItem, "AuctionTitle")%></h2></td>
</tr>
<tr>
<td><asp:LinkButton ID="btnimage" CommandName="imageclick" runat="server" CausesValidation="true" ><div class="overlap"><asp:Image Width="80px" Height="80px" ID="Image1" ImageUrl=' <%# Bind("ImageNm", "~/Admin/ProductImages/{0}") %>' runat="server" /><asp:Image ID="sold_small" src="Images/sold_small_en.png" alt="bar" runat="server" Visible="false"/></div></asp:LinkButton></td>
</tr>
<tr>
<td class="tab"><asp:Label ID="lblbidprice" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CurrentProductPrice") %>' style="padding-left:20px; font-weight:bold;color:#FFF;font-size:16px;"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblTimeWatch" runat="server"
style="color:#0099FF; font-weight: 600; font-size: 20px"
Text='<%# DataBinder.Eval(Container.DataItem, "timeDiff") %>'
></asp:Label>
<asp:Label ID="lblTimeWatch1" runat="server"
style="color:#0099FF; font-weight: 600; font-size: 22px" ></asp:Label>
<asp:Timer ID="BidTimer" runat="server" Interval="1000" ontick="BidTimer_Tick">
</asp:Timer>
<input id="mseconds" runat="server" type="hidden" />
<input id="second" runat="server" type="hidden" />
<input id="minute" type="hidden" runat="server" />
<input id="hour" type="hidden" runat="server" />
<input id="day" type="hidden" runat="server" />
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td id="tdbidder" runat="server" height="10" align="center">
<asp:DataList ID="dlbidder" runat="server" GridLines="None">
<ItemTemplate>
<span class="name"><%#Eval("UserId") %></span>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td >
<asp:LinkButton ID="btnBid" runat="server" CommandName="select" CausesValidation="true"><asp:Image ID="imgFolder" runat="server" ImageUrl="~/Images/btn_bid.png" /></asp:LinkButton>
</td>
</tr>
<tr>
<td align="center" >
<div id="boxbtmbynow" style="vertical-align:middle;">
<asp:LinkButton ID="A1" runat="server" CommandName="buynow"><font style="font-weight:bold; color: White;">Buy Now:<span><img alt="rs" src="Images/10px inr.png" /></span>
<%#DataBinder.Eval(Container.DataItem, "Price")%></font></asp:LinkButton>
</div>
</td>
<%--<td>
<b>Buy Now:</b>
<span><img alt="rs" src="Images/10px inr.png" /></span>
<%#DataBinder.Eval(Container.DataItem,"Price") %>
</td>--%>
</tr>
<tr><td class="btm"></td></tr>
</table>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</ContentTemplate>
</asp:UpdatePanel>
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'
Reply
Answers (
0
)
how to solve the semaphore problem in threads see my situation
how to get IP window os area browser