Aug 31, 2009, 4:35 PM
Getting "Could not cast or convert from System.String to System.DateTime" Exception if DataField is not entered from the user interface in Editable Grid
I have a store defined as follows :
Could not cast or convert from System.String to System.DateTime.
<ext:Store ID="storeRetailers" runat="server" OnBeforeStoreChanged="storeRetailers_BeforeChange">
<Reader>
<ext:JsonReader ReaderID="RetailerId">
<Fields>
<ext:RecordField Name="RetailerId" />
<ext:RecordField Name="EngagedDate" Type="Date" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
In the editable grid column config is as follows:<ext:Column DataIndex="EngagedDate" Header="Engagement Date">
<Renderer Format="Date" FormatArgs="'d/m/Y'" />
<Editor>
<ext:DateField ID="txtEngagedDate" runat="server" AllowBlank="true" MsgTarget="Under" Format="dd/MM/yyyy"/>
</Editor>
</ext:Column>
But while saving the grid data, I am getting following exception If EngagementDate is not supplied from user interface.Could not cast or convert from System.String to System.DateTime.
protected void contactStore_BeforeChange(object sender, BeforeStoreChangedEventArgs e)
{
ChangeRecords<ContactVO> data = e.DataHandler.ObjectData<ContactVO>(); // <-- Exception
}
Can you please give me some clue to resolve this ?