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

Example of RadComboBox in RadGrid

4 Answers 190 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 25 Sep 2008, 06:31 PM
I have a grid where the values for one of the columns should be unique across all rows. I want to make it so that when they edit a row, the drop list for that column filters out the previously selected items so that it is not possible to add or change a row which would create a duplicate.

The column in question is a GridTemplateColumn which contains a RadComboBox. Right now, I'm resetting the DataSource and calling DataBind on the combobox in the grid's ItemDataBound event (when the item is a GridEditableItem).

However, when I hit the InsertCommand or UpdateCommand events, the SelectedValue of the combobox is always empty.

Is there is an example that demonstrates the dynamic loading of a RadComboBox used in a GridTemplateColumn in which the combo box is loaded at runtime based on the existing row's values and demonstrates the inserting and updating? That means no use of DataSource objects like ObjectDataSource, AccessDataSource, SessionDataSource etc. in the example.

4 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 29 Sep 2008, 12:58 PM
Hello Thomas,

How you can set the SelectedValue when RadComboBox is placed inside RadGrid you can see here.
You can also set the SelectedValue property of RadComboBox in ItemDataBound event of RadGrid.

How you can insert and update items you can see here.

Regards,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Thomas
Top achievements
Rank 1
answered on 29 Sep 2008, 04:40 PM
I discovered the problem and it apparently had nothing to do with my approach. In general, I have used the ItemDataBound event to populate the combo and am able to get the combo's SelectedValue property in the InsertCommand and UpdateCommand. The problem I was encountering is that the grid itself was getting rebound.

Here was the scenario. I have a screen with three or four comboboxes at the top of a form and a grid of results below. Previously, I had the system updating the grid when someone changed any of the comboboxes. I was also using an AjaxProxy. When I fired one of the comboboxes, the system was firing the SelectedIndexChanged event for all of the other comboboxes! Since each of those event handlers rebound the grid, the grid was getting rebound a bunch of times and the effect was that the SelectedValue property was always empty.
0
Rosi
Telerik team
answered on 30 Sep 2008, 09:10 AM
Hello Thomas,

Do you still experience the problem?

All the best,
Rosi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Thomas
Top achievements
Rank 1
answered on 30 Sep 2008, 04:23 PM
Tough to say as I reworked the page to use a button. I.e., instead of triggering a refresh of the grid off the combo's SelectedIndexChanged event, I had the refresh trigger off a single button's Click event.
Tags
ComboBox
Asked by
Thomas
Top achievements
Rank 1
Answers by
Rosi
Telerik team
Thomas
Top achievements
Rank 1
Share this question
or