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

[Solved] OnClientSelectedIndexChanged with only RadComboBoxItem

2 Answers 159 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Kurt Boeckman
Top achievements
Rank 1
Kurt Boeckman asked on 08 Sep 2009, 05:06 PM
Greetings,

I create a RadComboBox at runtime based on a user's selection of items in a grid.  As the user selects items in the gird, I add an entry to the RadComboBox.  The RadComboBox serves as a 'breadcrumb' strategy to move the user back to a position in the grid based on what they've selected in the RadComboBox.  I use the OnClientSelectedIndexChanged event to reposition the user's location in the grid.  My problem is this strategy fails when only one item is found in the RadComboBox.  Clearly, OnClientSelectedIndexChanged won't work because they can never change the selected item.  Can anybody suggest a strategy to avoid this problem or to overcome it?  It would be nice to handle a RadComboBoxItem click event but I don't see that as supported.  I could add a blank item to the combo box, but it does not meet user requirements.  Any suggestions would be appreciated.  Thanks.

2 Answers, 1 is accepted

Sort by
0
Casey
Top achievements
Rank 1
answered on 08 Sep 2009, 05:28 PM
Hi Kurt,

I'm not sure what the requiremetns are, but in situations where there is only 1 item in the ComboBox, couldn't you automatically move the user back to the position in the grid? Or on the ItemCreated event of the ComoBox make sure there are no items selected, so when the user clicks the SelectedIndex does change.

Casey
0
Kurt Boeckman
Top achievements
Rank 1
answered on 15 Sep 2009, 03:47 PM
I found a solution.  Its not the greatest in the world, but it works.  I added the onclick attribute to the RadComboBoxItem when they are created programmatically.  For example:

RadComboBoxItem item = new RadComboBoxItem(item.Value, item.Key);
item.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(this.CommandButton, args);
radCombo.Items.Add(item);

The 'CommandButton' is a hidden input field that handles what the SelectedIndexChanged would normally do for me. This appears to be working.

Tags
ComboBox
Asked by
Kurt Boeckman
Top achievements
Rank 1
Answers by
Casey
Top achievements
Rank 1
Kurt Boeckman
Top achievements
Rank 1
Share this question
or