K
Keith Jackson
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.
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.