I have a scenario where one column in the table is a timestamp (date + time). I have my grid column configured as follows:
The property is coded as:
The display part is working fine: an example of the value displayed is: 12/20/2020 18:40:00
The problem I have is when adding a new row or editing an existing row. When adding a new row, the grid displays an empty row, and if I type in "12/20/2020 18:40:00" and tab out of the column to go to the next column, the timestamp column value is set to NULL (when putting a breakpoint on setter) and the timestamp I entered is wiped out. If I just type the date part (12/20/2020) and tab out, things work fine: the value is set correctly and the column displays "12/20/2020 00:00:00". I observe similar behavior when trying to edit a row. Do I need to specify a mask, a converter, or something else to get the column to properly accept the timestamp?
Thanks
Andrey
<
telerik:GridViewDataColumn
UniqueName
=
"Timestamp"
DataMemberBinding
=
"{Binding Timestamp}"
Header
=
"Timestamp"
DataFormatString
=
"{} {0:MM/dd/yyyy HH:mm:ss}"
IsFilterable
=
"False"
/>
The property is coded as:
public DateTime? Timestamp
{
get
{
... returns either NULL or datetime object
}
set
{
_timestamp = value;
}
}
The display part is working fine: an example of the value displayed is: 12/20/2020 18:40:00
The problem I have is when adding a new row or editing an existing row. When adding a new row, the grid displays an empty row, and if I type in "12/20/2020 18:40:00" and tab out of the column to go to the next column, the timestamp column value is set to NULL (when putting a breakpoint on setter) and the timestamp I entered is wiped out. If I just type the date part (12/20/2020) and tab out, things work fine: the value is set correctly and the column displays "12/20/2020 00:00:00". I observe similar behavior when trying to edit a row. Do I need to specify a mask, a converter, or something else to get the column to properly accept the timestamp?
Thanks
Andrey