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

GridDropDownColumn with customized items on edit, inserts null

1 Answer 36 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 11 Nov 2009, 03:20 PM
Hi guys,

Ok, so essentially, I have a grid where the first column is a valuation type.  There should only be one of each valuation type in the whole grid, although there does not necessarily need to be one of each.

ie: I have four types, there doesn't need to be four rows, but there must not be two rows with the same valuation type.

Using the code in Customize/Configure GridDropDownColumn when a row is being inserted, I rebind the editor to a new query which excludes any previously used types.  This works perfectly.  The problem is that when the row is inserted, the value of the type (the ID of the lookup value) is null.

I have traced this through at least some of the events.  I use the grid bound to a LinqDataSource (quick prototyping).  If I debug the InsertCommand event from the grid, I can check the value of the combobox and it is correct.  However by the time it reaches the linq classes and datasource, the value is null.

Does anyone have any ideas?  I know you might need more code, or detail, but I didn't want to post a whole bunch of code here if it was really a waste of time because I'm being so obviously stupid somewhere else.

Thanks,
Adam.

1 Answer, 1 is accepted

Sort by
0
Prangadj
Top achievements
Rank 1
answered on 16 Nov 2009, 02:23 PM
I think that it is expected to have the id from the lookup table as null on initial insertion - after all new item in the source still does not exist. Later, when you perform the actual insertion on insert command and item is selected in the dropdown, its value should be available as well to extract it from the dropdown item and update the data source.

Getting value from column editors in code is shown here.

Tags
Grid
Asked by
Adam
Top achievements
Rank 1
Answers by
Prangadj
Top achievements
Rank 1
Share this question
or