views:

77

answers:

2

I have the following template defined within DetailsView ( DetailsView is bound to object data source ):

    <EditItemTemplate>
       <asp:TextBox ID="txtReleaseDate" runat="server" 
               Text='<%# Bind("ReleaseDate", "{0:d}") %>'>
       </asp:TextBox>
       <asp:CompareValidator ID="valReleaseDateType" runat="server"
               ControlToValidate="txtReleaseDate" Type="Date" Operator="DataTypeCheck"
               Display="Dynamic" > * 
       </asp:CompareValidator>
   </EditItemTemplate>

Assuming I enter into TextBox txtReleaseDate a date in format month/day/year, then upon clicking an Update or Insert button, a CompareValidator control complains that date format is not valid. But if I enter date in format day/month/year, then object data source throws an exception Cannot convert value of parameter 'releaseDate' from 'System.String' to 'System.DateTime', while CompareValidator doesn’t complain.

I need the two controls to accept the same date format, so:

a) Since my DB stores date in format day/month/year, the best option would be for ODS to also accept this as valid date format. Can ODS be configured that way?

b)Can CompareValidator be configured to also accept month/day/year format?

thanx

+1  A: 

Probably you can set the CurrentUICulture of thread to en-GB format.

Chinjoo
A: 

Try setting the web.config Globalization

I think format is "dd/MM/yyyy"

try putting "eb-US" one. Gud luck.

pjb