Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > ASP.Net 2 Two Way Binding and DateTime Format Problem

Reply
Thread Tools

ASP.Net 2 Two Way Binding and DateTime Format Problem

 
 
Ludovic DE FREITAS
Guest
Posts: n/a
 
      01-09-2006
Hello,

I have a ASP.Net page where I use the new two-way binding.
Unfortunatly the Update have problem with DateTime format.

I use a TextBox : <asp:TextBox runat="server" id="tbDate" Text='<%#
Bind("MyDate","{0:dd/MM/yyyy}") %>

The Binding (display) works, but the Update use another format "MM/dd/yyyy".
I have try to change the Thread Culture, the browser culture, the server
regional settings and nothing works.
I have check the UpdateItem with Reflector in FormView class, ans It seems
that the InvariantCulture is used to convert string to DateTime !!!

Can anyone help me with this problem ?

Thanks.
 
Reply With Quote
 
 
 
 
Phillip Williams
Guest
Posts: n/a
 
      01-09-2006
The solution lies in using the UpdateParameters collection to cast the
TextBox's date string format to an internal DateTime type.

If I build a web page that allows the user’s browser to determine the
display of the date, yet my database operates on a server using the culture
setting for en-us, then I would get an error that "Cannot convert value of
parameter 'OrderDate' from 'System.String' to 'System.DateTime' ":
http://www.webswapp.com/CodeSamples/..._2c_error.aspx

If I add an UpdateParameters section within my objectDataSource defintion to
explicitly cast the edited values to their appropriate date type, I do not
get that error as in this demo:
http://www.webswapp.com/CodeSamples/...idView_2c.aspx

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com


"Ludovic DE FREITAS" wrote:

> Hello,
>
> I have a ASP.Net page where I use the new two-way binding.
> Unfortunatly the Update have problem with DateTime format.
>
> I use a TextBox : <asp:TextBox runat="server" id="tbDate" Text='<%#
> Bind("MyDate","{0:dd/MM/yyyy}") %>
>
> The Binding (display) works, but the Update use another format "MM/dd/yyyy".
> I have try to change the Thread Culture, the browser culture, the server
> regional settings and nothing works.
> I have check the UpdateItem with Reflector in FormView class, ans It seems
> that the InvariantCulture is used to convert string to DateTime !!!
>
> Can anyone help me with this problem ?
>
> Thanks.

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [2.4.4] creating a datetime.datetime from an XML xs:dateTime skip@pobox.com Python 2 01-06-2009 01:31 PM
[2.4.4] creating a datetime.datetime from an XML xs:dateTime Martin Python 0 12-27-2008 08:08 PM
mx.DateTime to datetime.datetime mp Python 1 07-28-2006 10:57 PM
datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ? Christos TZOTZIOY Georgiou Python 3 09-13-2003 10:44 AM
RE: datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ? Tim Peters Python 0 09-09-2003 12:57 AM



Advertisments