the default should be setting to "0", but instead it is picking "Key170-1", but when I pick "Key360-7", as soon as the combo loses focus, it magically reverts back to "Key170-1".
9 Answers, 1 is accepted
I have several Rad ComboBoxes on the page, and one of them does not work.
That one has the same behavior as yours, it has 3 items (not template items, just standard ones) The 1st one just says "Select..." and has a value of -1, the other two have some random binary strings and the values are 0.
Whenever I Select the 3rd item, and then change the focus to the page or another control, it automatically selects the 2nd item.
The only thing different about the control that is different than the others is that it is dynamically added to the page using LoadControl(...); and Controls.Add(...); and it is a user control embedded within another user control.
I tried putting breakpoints in all different parts of the page load and the setting of the combo box values, and the selected index changed event and none of these methods are triggered when the automatic selection occurs, it may be something on the client side.
All of my combos use a Long key and a String description, except the last one, which uses a String key. Dohn! All of my code in my BaseComboBox was using Long keys and it was failing out on that last one where the Key was a string. Now, why I couldn't trap this error and why I couldn't step through it is still a mystery to me. The mysterious behaviour is troublesome, though I found and fixed the cause in my situation.
Could you be a little more specific about what you mean by "Key" and "Description"
Are you referring to the DataTextField and the DataValueField properties of the RadComboBox and what the data types are in the DataSource items?
I just want to make sure I understand in case I'm not doing something similar.
Yes. We use SubSonic for our Data Access Layer. I created a BaseComboBox that inherits from the RadComboBox and adds the functionality to Bind itself to a Subsonic.Select query result. The function that creates the list is shwon below. Yesterday, this was converting the rdr.GetValue(0) into a Long and passing it in as a long to lst.Add. That was the code I changed, and now my combos are behaving predictably. Here is the code:
Private Shared Function ParseQueryIntoListItems(ByVal qry As [Select]) As IList(Of RadComboBoxItem)
'run the query, get back a Reader
Dim rdr = qry.ExecuteReader()
Dim lst As New List(Of RadComboBoxItem)()
'loop through the reader, creating ListItems
Dim id = rdr.GetValue(0)
Dim text = rdr.GetString(1)
lst.Add(New RadComboBoxItem(text, id))
'Add a blank row with a key of "0"
lst.Add(New RadComboBoxItem("", "0"))
This function result is then passed back to this function, which clears the Items collection and reloads it from the IList(Of RadComboBoxItem):
Private Sub MainLoadItems(ByVal id As String, ByVal parentIdfk As String, ByVal filterText As String, ByVal whereClauses As IList(Of Constraint))
Me.Items.AddRange(GetListItems(id, parentIdfk, filterText, whereClauses))
Hope that helps,
Had you any success?
I have the same behavior like you:
Three RadComboBoxes created by code and they are using the event ItemsRequested.
One rcb jumps back to first item, when I click on the page.
Sorry I didn't post this sooner...
Turns out the reason this was happening to me was because I had multiple items in my combo box with the same Value.
Actually, in my case all of the items had the same value, becuase I was not actually using the value and just the text in the combo box, I had set the value of all the items to be -1.
Turns out, when a combo box has more than one item with the same value, after selection of one of those items, it will select the 1st one with that value.
I fixed mine by making sure that all my combo box items had distinct values.
Hope this helps, T.J.
Thanks for the hint, my values were the same too.
This behaviour is still same in Version=2008.3.1125.35.
I had the following dataset
In my datavalue settings of combo I had recordid and in my datatext week.
Combo will revert to week1 no matter what week is selected.
As in other posts I want to confirm solution is that each record must be unique.
I was only using week cmbweek.selecteditem.text so I change my value settings to week as well.
Yes, the values of the combo items should be different.
All the best,
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.