HighTechTalks DotNet Forums  

ObjectDataSource DateTime Localisation bug

ASP.net Announcements microsoft.public.dotnet.framework.aspnet.announcements


Discuss ObjectDataSource DateTime Localisation bug in the ASP.net Announcements forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Keith Jackson
 
Posts: n/a

Default ObjectDataSource DateTime Localisation bug - 01-31-2006 , 10:42 AM






I have, over the last week, been attempting to play with the
ObjectDataSource binding an ASP.NET 2.0 UI through to a Data Access
Assembly.

Selection of data using the new GridView control worked flawlessly but, on
attempting any kind of data writing, the system produced the following
error...

"The DateModified field could not be converted from System.String to
System.DateTime"

I tried manually entering US format dates (I am UK based) - this worked. I
then tried setting up the Application culture settings for en-GB but no joy.

It seems that the ObjectDataSource is forcing use of the American date
format. There are three workarounds for this bug...

1) Set the application culture settings to en-US and use American date
format (i.e. Give up!).

2) Pass DateTime types to the DAL Object as strings and convert the exposed
property to an internal DateTime field.

3) Catch the Update by adding an event handler to the Page, as follows.

protected void GridView_RowUpdating(object sender, GridViewUpdateEventArgs
e)

{

e.NewValues[19] = Convert.ToDateTime(e.NewValues[19].ToString());

e.NewValues[20] = Convert.ToDateTime(e.NewValues[20].ToString());

}

Either of these solutions solve the above problem.



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.