Welcome Guest Search | Active Topics | Sign In | Register

Grid with Datetime column does not save changes if value had been null Options
Code Monkey
Posted: Friday, April 18, 2008 12:28:54 PM
Rank: Advanced Member
Groups: Member

Joined: 2/11/2008
Posts: 37
If you run your demo "Edit Grid Data - Excel Style" after editing the data in the demo.mdb file, setting a few of the datetime's in the Topics table to null, then when you set a date for the previously null field and click the postback button, the new value is not saved.

Am I doing something wrong? Thanks!
eo_support
Posted: Saturday, April 19, 2008 3:09:38 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
Hi,

The Grid can populate its initial value from your data source, but it never saves the data back into your data source for you. All the changes are kept by the Grid and you will need to handle its server side event to save the changes. A normal flow is like this:

1. Grid populates from your data source;
2. User modifies the data;
3. ItemChanged event is fired;
4. Your code checks the Grid's ChangedItems property and saves the change back to your data source;

Note step 4 is done by your code, not he Grid.

Thanks
Code Monkey
Posted: Sunday, April 20, 2008 11:11:43 AM
Rank: Advanced Member
Groups: Member

Joined: 2/11/2008
Posts: 37
Ok, let me be more clear.

The new value does not show in the ChangedItems list. The cell shows as modified but the new value is missing. I used your own demo as an example so that you wouldn't think I coded anything wrong. All you have to do to see the problem is set some date values to null in your demo.mdb.

Thank you.
eo_support
Posted: Sunday, April 20, 2008 12:03:49 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
Sorry that we have missed the point! :) We have posted a new build (2007.2.50) that fixed this issue. Please see your private message for download location.
Code Monkey
Posted: Sunday, April 20, 2008 1:43:57 PM
Rank: Advanced Member
Groups: Member

Joined: 2/11/2008
Posts: 37
Build 2007.2.50 does fix this problem, thank you.

I will note that if you click on a datetime cell that was null, and then postback, the new value for that cell in ChangedItems is "1/1/0001 12:00:00 AM". I'd prefer it to be "" or something but I can live with it as is.

Thanks again.
eo_support
Posted: Monday, April 21, 2008 6:28:43 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
Thanks for your feedback. DatePicker does not have a null value, that's why as soon as you edited the cell, you no longer have the null value. The value is changed to DateTime.MinValue so that it can be distinguished whether user has edited the cell and also facilitate some whose database does not accept null value.
Code Monkey
Posted: Monday, April 21, 2008 6:39:48 AM
Rank: Advanced Member
Groups: Member

Joined: 2/11/2008
Posts: 37
Ok, thanks again.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.