Wrox Programmer Forums
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 12th, 2006, 11:00 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 107
Thanks: 1
Thanked 8 Times in 7 Posts
Default Gridview, Eval and Current Time

Please help me, I have a mental block on this one.

I have a field in a table identifying the difference for each country between their local time and GMT.

I would like to display in a gridview templated control the current time plus the adjustment for GMT difference to show the current local time.

Can anyone help?


__________________
Try our latest project www.nobanx.com Currency Exchange for members
 
Old September 15th, 2006, 07:16 AM
Authorized User
 
Join Date: Sep 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

As per your requirement as I tried to understand, you have the difference from each country against their local time and GMT already in the table right. So you could try and achieve the same using an SQL query, by adding/substracting the time as per the location.



Vincent Thomas
Bangalore
 
Old September 20th, 2006, 05:50 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 107
Thanks: 1
Thanked 8 Times in 7 Posts
Default

I'm re-visiting this an have ended up with the following

In the Gridview I have:

<asp:TemplateField HeaderText="Local" SortExpression="BranchGMT">
  <ItemTemplate>
     <asp:Label ID="Label1" runat="server" Text='<%# Eval("BranchGMT", LocalTime("BranchGMT")) %>'></asp:Label>
  </ItemTemplate>
</asp:TemplateField>


I have created a function


    Protected Function LocalTime(ByVal GMTDiff As String) As String
        Dim CurrentTime As Date = Now()
        Dim LT As Date
        Dim GMT As Integer
        GMT = CInt(GMTDiff)
        LT = CurrentTime.AddHours(GMT)
        Return LT
    End Function


When I run this it doesn't send the value of the BranchGMT field to GMTDiff (it goes across as "BranchGMT" and not the value).

Can anyone let me know what I need to do to send the correct value to the function please?

Thanks


 
Old September 20th, 2006, 06:06 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 107
Thanks: 1
Thanked 8 Times in 7 Posts
Default

It works now just by using:

<asp:Label ID="Label1" runat="server" Text='<%# Eval("BranchGMT", LocalTime(Container.DataItem("BranchGMT"))) %>'></asp:Label>

instead of
<asp:Label ID="Label1" runat="server" Text='<%# Eval("BranchGMT", LocalTime("BranchGMT")) %>'></asp:Label>

:D

Mental block is now cleared, I'm just waiting for the hair to grow back now!








Similar Threads
Thread Thread Starter Forum Replies Last Post
get the current system data and time arunprasadlv XSLT 6 May 7th, 2008 07:43 AM
Current Date and Time in XSLT devMc XSLT 6 October 21st, 2007 04:49 AM
getting current date and time in xslt 1.0 ashyabhi_hp XSLT 1 September 24th, 2007 03:17 AM
Check to See if Current Time is between hours mvollmer Classic ASP Professional 5 July 28th, 2004 07:49 PM
sql - comparing current time suzila VB.NET 2002/2003 Basics 7 May 14th, 2004 12:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.