This is a migrated thread and some comments may be shown as answers.

CellEndEdit e.Value is null

2 Answers 68 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jan Pfeffer
Top achievements
Rank 1
Jan Pfeffer asked on 22 Aug 2011, 11:01 AM
Hey at Telerik

I have a problem when binding gridview to a List<Car>.
The Car object contains two objects Engine and CarColor.

If an Engine or CarColor is initialized on the car object the e.Value in the

 

rgvCars_CellEndEdit event is correctly changed and parsed and object is updated.

If no Engine or CarColor object is initialized on the Car object and i try to set for instance and engine in the combobox, the e.Value in  the rgvCars_CellEndEdit event is null and the object is not updated.

How do i set an Engine or CarColor on the Car object if there's no Engine or CarColor initialized ??

I have include an example (Without an assembly) that shows the problem at hand when you try to select for intance an Engine on the Car that doesn't have an Engine object initialzed.

Link to example. http://kort2.lifa.dk/Examples/GridViewCellEndEditIssue.zip

Sincerly Jan

2 Answers, 1 is accepted

Sort by
0
Christian
Top achievements
Rank 1
answered on 22 Aug 2011, 05:44 PM
hi !

thank you for the sample, on train i checked around a little and found that
if you rename your "navigatoin-properties"/columns from:

FieldName: Engine.Name  to  Car.Engine.Name ,
FieldName: CarColor.Color Car.CarColor.Color

the update works, but initialisation is somehow wrong. i see you use a singleton for the controller, that's nice ... i have to get off train now ... but maybee it helps getting closer...
....
erm update:
 
but if you want car to have only 1 engine, which might be what you wanted to say ;) ... the fields should be renamed like that:

FieldName: Engine.Name  to  Name ,
FieldName: CarColor.Color to Color

is see you named them correct  in code , but in this case the defined columns in designer seem to be used ....
0
Accepted
Stefan
Telerik team
answered on 24 Aug 2011, 02:57 PM
Hello Jan,

Thank you for writing.

The Value in the CellEndEdit method is null because there is no corresponding object initialized for this field. What you can do is make sure that the the fields are initialized on CellBeginEdit and if they are not, you can initialize them manually. Please refer to the attached project, where I have introduced the necessary changes to check if the Engine and CarColor fields are initialized. 

I hope that you find this information helpful.

Best wishes,
Stefan
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
GridView
Asked by
Jan Pfeffer
Top achievements
Rank 1
Answers by
Christian
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or