Hi
We have "datarow" in class and "dataset" is from ObservableCollection. There are normal set and get for public properties. We use ObjectDataSource to get "dataset" and there are also insert, update and delete commands. All other things seems to work but we have problems with DateTime type properties. Those are tested in GridBoundColumn and GridDateTimeColumn and always same problem. Those are shown correctly with user date format or given datastringformat but when updating or inserting it always crash before our own codes to conversion from "System.String" to "System.DateTime". Only way we have got it work properly is use ISO standard type format "yyyy-MM-dd HH:mm:ss" when setting the value which is not acceptable way to work. So how these datetimes should be set to columns that those are shown and editable in user format and not crash somewhere before it even get to our own code?
5 Answers, 1 is accepted
Note that when you are using DateTime column or a Bound column with DateTime set the System.DateTime you should pass DateTime type of fields form the DB to those columns. Otherwise you should perform manual conversion of the data before inserting it into the DB.
Regards,
Maria Ilieva
Telerik
Hi
We are using DateTime from db (Oracle db field named EnrollmentDate type Date) to class properte (Enrollment class with property EnrollmentDate) to observablecollection with that class (ObservableCollection<Enrollment>) and to asp elements.
Below are two asp parts (Bound or DateTime) which has been tested:
<
telerik:GridBoundColumn
DataField
=
"EnrollmentDate"
HeaderText
=
"EnrollmentDate"
SortExpression
=
"EnrollmentDate"
UniqueName
=
"EnrollmentDate"
DataType
=
"System.DateTime"
FilterControlAltText
=
"Filter EnrollmentDate column"
></
telerik:GridBoundColumn
>
<
telerik:GridDateTimeColumn
DataField
=
"EnrollmentDate"
HeaderText
=
"EnrollmentDate"
SortExpression
=
"EnrollmentDate"
UniqueName
=
"EnrollmentDate"
DataType
=
"System.DateTime"
FilterControlAltText
=
"Filter EnrollmentDate column"
></
telerik:GridDateTimeColumn
>
In Class "Enrollment" that property "EnrollmentDate" is defined as follows:
public
DateTime? EnrollmentDate
{
get
{
return
_EnrollmentDate;
}
set
{
_EnrollmentDate = value;
OnPropertyChanged(
"EnrollmentDate"
);
}
}
Setting data to that class property from DB:
objEnrollments.EnrollmentDate = dr.Field<DateTime?>(
"EnrollmentDate"
);
So where is the problem point?
If there is no problem, where is your mentioned before inserting, because it crash just after clicking update/insert button and not go in any event (or I haven't find right one).
BR
Harri
Can you please send us the full error stack trace so that we can revise it locally and investigate further for its root cause?
Regards,
Maria Ilieva
Telerik
Hi,
Sorry for long reply, some other projects :) Co worker found that there is solution for this. That was adding ParsingCulture="Current" to ObjectDataSource which we used for grid. So there is no more problems with datetime (or decimal numbers).
Regards,
Harri
Thank you for getting back to us and for the provided update on this case. Do not hesitate to contact us back in case further assistance is needed.
Regards,
Maria Ilieva
Telerik by Progress