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

Grid row won't go into edit mode if combo selectedvalue not found

3 Answers 25 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 23 Feb 2011, 12:53 AM
Hi there.

I have a RadComboBox in an EditItemTemplate in a radgrid with SelectedValue='<%# Bind("OrgClassification3") %>'. If the value of OrgClassification3 is empty or matches a value in the combo then everything works fine and I can edit the row and save changes. If the value of OrgClassification3 does not match any of the values in the combo the grid row will not even go into edit mode.

Please help. Thanks.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 23 Feb 2011, 05:19 AM
Hello Christ,

I am not quite sure about the issue. Normally it will return an an error when the value you set as selected in the RadComboBox does not exist in the list of Items already loaded in the control. In case where the bound column allows NULL values, the best way to avoid the error is to select empty strings instead of the NULLs or convert them to empty strings after the data is selected. Finally, an Item with value = String.Empty or "" should exist in the ComboBox. So in order to avoid server exception when passing null value to the combobox, try setting AppendDataBoundItems = true and include an empty item to the RadComboBox control.

Also refer to this kb article to get more information on Using RadComboBox as editor in template column of RadGrid

Thanks,
Princy.
0
Chris
Top achievements
Rank 1
answered on 23 Feb 2011, 05:28 AM
Thanks Princy.

My question was more about how to gracefully handle the error when my selectedvalue does not exist in the combo. I cannot always guarantee the selectedvalue will exist in the combo so I want the control to just ignore it and load as normal. The user will then be forced to select a choice from the combo.

Thanks
Chris
0
Nikolay Rusev
Telerik team
answered on 28 Feb 2011, 10:34 AM
Hello Chris,

The behavior is the same as if you bind DropDownList and set SelectedValue to an item that does not exist.

Regards,
Nikolay
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Chris
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or