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 May 8th, 2009, 08:56 AM
Authorized User
 
Join Date: Dec 2006
Posts: 36
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Yahoo to deb1980
Default Datetime in label

Hi,

When I try to fill a label with the datetime which has been fetched from the db - I get the following error.

Cannot implicitly convert type 'System.DateTime' to 'string'

The C# file has the following code:

lblEventDate.Text = System.Convert.ToDateTime(oEvents2.__StartDate);

where oEvents2 is the object of the class from where I'm fetching the record and __Startdate is the property set.

Please suggest.
__________________
---
Best regards,

Debashis
http://debashis80.spaces.live.com/
 
Old May 8th, 2009, 10:43 AM
Lee Dumond's Avatar
Wrox Author
 
Join Date: Jan 2008
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

lblEventDate.Text = (System.Convert.ToDateTime(oEvents2.__StartDate)).ToString();
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 
Old May 9th, 2009, 07:37 AM
Authorized User
 
Join Date: Dec 2006
Posts: 36
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Yahoo to deb1980
Default

thanks lee
__________________
---
Best regards,

Debashis
http://debashis80.spaces.live.com/
 
Old May 11th, 2009, 03:37 AM
Registered User
 
Join Date: Sep 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hi.huangls
Default

if you want to use the datas on controls ,first of all,you must cast the type of the data which you have been fetched to String type..





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to see a label hombre Java Basics 3 March 4th, 2008 06:15 AM
datetime scandalous SQL Server 2005 3 December 19th, 2007 10:33 AM
datetime MathLearner Beginning VB 6 0 November 15th, 2007 07:12 AM
UTC DateTime to Local DateTime r_ganesh76 SQL Server 2000 1 April 4th, 2005 08:21 AM
DateTime DARSIN General .NET 1 December 1st, 2004 06:24 AM





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