I've seen this posting a few times in the forums, but no clear answer.
We recently upgraded from 2008.Q1 to 2008.Q2. After upgrading, we are getting an error that is somewhat predictable. When the error occurs, the exception is raised within the DataBind() event for the RadComboBox. In order to make sure the data coming from the stored procedure was not causing the problem, we overwrote the stored proc to return a static set of data. Considering I have seen other cases reported in the forums for previous versions of this control having the same issue, it looks like your previous fix may have been broken with this most recent release.
Here is the code to populate the combobox - we use almost identical code everywhere we populate the combobox:
I added the ClearSelection call in line 5 after reading a forum entry, but it does not solve the problem.
In case this information is important... we are using DotNetNuke 4.8.3 and the module in which this code exists is using partial page rendering. In this situation, the user is selecting a row from a grid and then clicking a button called "edit". This causes the panel with the grid to dissappear and then a panel with the RadComboBox is made visible, during this button click event is where the combobox population code shown above is called. The predictability of the error is in that I can select an item, click edit, return (hide panel with combo and make grid panel visible again), select another item, click edit, return, click the original item, click edit...kaboom. It would not be easy to send a project that isolates the error for you. The DNN module we have in this case is fairly straightforward, though. There is nothing fancy happenning, just what I mentioned when the edit button is clicked.
We really need this resolved immediately as we have a major deliverable for a client. Please advise.
Thanks!
Michael
We recently upgraded from 2008.Q1 to 2008.Q2. After upgrading, we are getting an error that is somewhat predictable. When the error occurs, the exception is raised within the DataBind() event for the RadComboBox. In order to make sure the data coming from the stored procedure was not causing the problem, we overwrote the stored proc to return a static set of data. Considering I have seen other cases reported in the forums for previous versions of this control having the same issue, it looks like your previous fix may have been broken with this most recent release.
Here is the code to populate the combobox - we use almost identical code everywhere we populate the combobox:
| //populate parent categories | |
| rcbParentCategory.DataSource = ourDB.Category_GetAvailableParents(CurrentCategoryId); | |
| rcbParentCategory.DataValueField = "CategoryId"; | |
| rcbParentCategory.DataTextField = "CategoryName"; | |
| rcbParentCategory.ClearSelection(); | |
| rcbParentCategory.DataBind(); | |
| rcbParentCategory.Items.Insert(0, new RadComboBoxItem("None Selected", "-1")); | |
| rcbParentCategory.SelectedValue = | |
| ((rcbParentCategory.Items.FindItemByValue(category.ParentId.ToString()) != null) ? category.ParentId.ToString() : "-1"); | |
| rcbParentCategory.DataSource = null; |
I added the ClearSelection call in line 5 after reading a forum entry, but it does not solve the problem.
In case this information is important... we are using DotNetNuke 4.8.3 and the module in which this code exists is using partial page rendering. In this situation, the user is selecting a row from a grid and then clicking a button called "edit". This causes the panel with the grid to dissappear and then a panel with the RadComboBox is made visible, during this button click event is where the combobox population code shown above is called. The predictability of the error is in that I can select an item, click edit, return (hide panel with combo and make grid panel visible again), select another item, click edit, return, click the original item, click edit...kaboom. It would not be easy to send a project that isolates the error for you. The DNN module we have in this case is fairly straightforward, though. There is nothing fancy happenning, just what I mentioned when the edit button is clicked.
We really need this resolved immediately as we have a major deliverable for a client. Please advise.
Thanks!
Michael
17 Answers, 1 is accepted
0
Michael
Top achievements
Rank 1
answered on 31 Jul 2008, 03:19 PM
OK, I found a work around, but it pretty much proves that your DataBind() method does, in fact, have an issue.
Here is the workaround I used. Quite honestly, it will be a big deal to go through our entire web application and change all the code for the combo boxes to use this workaround.
So, by adding them all manually, all is fine.
Even though there is a workaround, please address this issue to prevent us from having to go retrofit all of our code.
I appreciate your products and support very much!
Thanks!
Michael
Here is the workaround I used. Quite honestly, it will be a big deal to go through our entire web application and change all the code for the combo boxes to use this workaround.
| //temporary workaround for RadComboBox issue | |
| rcbParentCategory.ClearSelection(); | |
| rcbParentCategory.Items.Clear(); | |
| var parents = HarborSalesDB.Category_GetAvailableParents(CurrentCategoryId); | |
| foreach (var parent in parents) | |
| { | |
| rcbParentCategory.Items.Add(new RadComboBoxItem(parent.CategoryName.ToString(), parent.CategoryID.ToString())); | |
| } | |
| rcbParentCategory.Items.Insert(0, new RadComboBoxItem("None Selected", "-1")); | |
| rcbParentCategory.SelectedValue = | |
| ((rcbParentCategory.Items.FindItemByValue(category.ParentId.ToString()) != null) ? category.ParentId.ToString() : "-1"); | |
| rcbParentCategory.DataSource = null; |
So, by adding them all manually, all is fine.
Even though there is a workaround, please address this issue to prevent us from having to go retrofit all of our code.
I appreciate your products and support very much!
Thanks!
Michael
0
Hello Michael,
Could you please paste the definiton of your RadComboBox here? This will help us to reproduce the error at our side and to investigate the issue.
Regards,
Rosi
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Could you please paste the definiton of your RadComboBox here? This will help us to reproduce the error at our side and to investigate the issue.
Regards,
Rosi
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Michael
Top achievements
Rank 1
answered on 01 Aug 2008, 01:25 PM
Thanks for your attention in this matter!
Here is the declaration from the ascx:
Thanks!
Michael
Here is the declaration from the ascx:
| <telerik:RadComboBox ID="rcbParentCategory" runat="server" Width="90%" Skin="Vista" Height="150" | |
| DropDownWidth="250"> | |
| </telerik:RadComboBox> |
Thanks!
Michael
0
Hi Michael,
Please find the attached project based on your code which works as expected at our side. Could you please modify it so the problem to appear and send us steps to reproduce the issue?
Kind regards,
Rosi
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Please find the attached project based on your code which works as expected at our side. Could you please modify it so the problem to appear and send us steps to reproduce the issue?
Kind regards,
Rosi
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Michael
Top achievements
Rank 1
answered on 04 Aug 2008, 05:57 PM
Please make sure you are testing this issue under DotNetNuke before asking for me to reproduce the issue in a project. I simply do not have time, and since I have a workaround, I'd rather make the investment in fixing my code with the workaround and moving on than to work at reproducing the error for you to use to troubleshoot. I think I have provided ample evidence that there is some issue within the bind method of the grid with the code I have published in my post.
Thanks for your continued support. I wish I had more time to help, I just can't with the deadlines we are working under. Please do notify when you have a solution.
Thanks!
Michael
Thanks for your continued support. I wish I had more time to help, I just can't with the deadlines we are working under. Please do notify when you have a solution.
Thanks!
Michael
0
Michael
Top achievements
Rank 1
answered on 07 Aug 2008, 05:31 PM
Telerik,
Have you been able to verify this issue within a DotNetNuke module? Please advise on a solution to this issue.
Thanks!
Michael
Have you been able to verify this issue within a DotNetNuke module? Please advise on a solution to this issue.
Thanks!
Michael
0
Hi Michael,
We are still not able to reproduce the issue and we believe that this is not related with DNN.
However without a project or a sample module which illustrates the problem we are not able to find a solution.
Still, we will continue to search for the source of the problem and its solution and we will let you known as soon as we fix it.
Meanwhile I hope that you can sue the workaround which you found and apologize us for the inconvenience that this causes to you.
Regards,
Rosi
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
We are still not able to reproduce the issue and we believe that this is not related with DNN.
However without a project or a sample module which illustrates the problem we are not able to find a solution.
Still, we will continue to search for the source of the problem and its solution and we will let you known as soon as we fix it.
Meanwhile I hope that you can sue the workaround which you found and apologize us for the inconvenience that this causes to you.
Regards,
Rosi
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
mlandauer
Top achievements
Rank 1
answered on 13 Aug 2008, 10:16 PM
I also get this error in the Q2 release. I'm not using DNN. I have three RadComboBoxes. All are bound to separate ObjectDataSources. The SelectedValues of the first two combo boxes are used as SelectParameters for the ObjectDataSource of the third. I can reproduce the problem like this:
1. Hide the third combo box.
2. Change the selection of one of the first two combo boxes.
3. Show the third again.
4. Call DataBind() on the third, to bring it up to date with the changes in the first two. This call throws the exception.
I was able the trace it back to line 1111 of RadComboBox.cs. Seems to have something to do with the private fields cachedSelectedValue and cachedSelectedIndex.
I was able to work around it by setting the SelectedIndex to -1 before the DataBind() call.
1. Hide the third combo box.
2. Change the selection of one of the first two combo boxes.
3. Show the third again.
4. Call DataBind() on the third, to bring it up to date with the changes in the first two. This call throws the exception.
I was able the trace it back to line 1111 of RadComboBox.cs. Seems to have something to do with the private fields cachedSelectedValue and cachedSelectedIndex.
I was able to work around it by setting the SelectedIndex to -1 before the DataBind() call.
0
Hello mlandauer,
This error occurs in the following situation: an Item has been selected in a RadComboBox. Then the control is bound to another data source, which does not contain the value of the selected (cached) Item. The control tries to select the same Item, searching for it by its value, which does not exist, hence an Exception is thrown.
The workaround in this case is to clear the selection in the RadComboBox before binding it again (RadComboBox.ClearSelection()) or, as you have done already, reset the SelectedIndex.
Sincerely yours,
Simon
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
This error occurs in the following situation: an Item has been selected in a RadComboBox. Then the control is bound to another data source, which does not contain the value of the selected (cached) Item. The control tries to select the same Item, searching for it by its value, which does not exist, hence an Exception is thrown.
The workaround in this case is to clear the selection in the RadComboBox before binding it again (RadComboBox.ClearSelection()) or, as you have done already, reset the SelectedIndex.
Sincerely yours,
Simon
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
mlandauer
Top achievements
Rank 1
answered on 05 Sep 2008, 09:52 PM
This problem happens in more situations with Q2 SP1 than it did in Q2.
0
Morten
Top achievements
Rank 2
Iron
Iron
Iron
answered on 06 Sep 2008, 06:35 PM
calling ClearSelection() before DataBind() worked for me
0
Joseph Alves
Top achievements
Rank 1
answered on 11 Sep 2008, 11:06 AM
I work with the Q2 components and had the same thing when I updated to the last release (2008_2_826). Didn't have to add the ".clearSelection" line before, but I have to do it now to get the databind work again.
0
Steve
Top achievements
Rank 1
answered on 23 Sep 2008, 08:18 AM
I have the same issue with the latest release. It occurs after the combo box has been rebound several times. This happens due to the combo box items depend on the selected item in another combo box.
The 'dirty hack' I've used is to set the apend items flag to true and hide all the items in the combo box before I perform another databind. Its messy but does the trick.
Have the support team been able to reproduce the error?
Steve B.
The 'dirty hack' I've used is to set the apend items flag to true and hide all the items in the combo box before I perform another databind. Its messy but does the trick.
Have the support team been able to reproduce the error?
Steve B.
0
Hello there,
It is very likely that there is a problem manifesting in a similar way to the first one.
Could you provide more details on the matter? Code or instructions for reproducing the issue will be of great help.
Kind regards,
Simon
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
It is very likely that there is a problem manifesting in a similar way to the first one.
Could you provide more details on the matter? Code or instructions for reproducing the issue will be of great help.
Kind regards,
Simon
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
luc bonenfant
Top achievements
Rank 1
answered on 18 Nov 2008, 09:25 AM
I'm using Q2 2008 with DNN4, and I had the problem with this code :
I uncommented the line lsTest.ClearSelection() and the bug disappeared...
If Not lsTest.SelectedItem Is Nothing Then lsTest.SelectedItem.Selected = False
lsTest.Text = String.Empty
lsTest.Items.Clear()
'lsTest.ClearSelection() ' ----- commented ----
lsTest.DataSource = DT.DefaultView
lsTest.DataTextField =
"Text"
lsTest.DataValueField = "Value"
lsTest.DataBind()
I uncommented the line lsTest.ClearSelection() and the bug disappeared...
0
Michael Sumerano
Top achievements
Rank 2
answered on 07 Jul 2009, 01:08 PM
Just set up a combobox with an ObjectDataSource. Then, try using SelectedValue property on the combobox after a postback in a button click event. You will get the exception. This occurs because when using ObjectDataSource, you do not call DataBind and it tries to bind the data as late as possible (possibly in Render). This means, the combobox doesn't have its items yet and using the SelectedValue property will throw an exception because the item is not found.
0
Hi Michael Sumerano,
If you simply set the SelectedValue in a Button's Click event handler as you have suggested, the selection will be reset without the exception.
Kind regards,
Simon
the Telerik team
Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
Just for information, this is insufficient to trigger the exception. Basically the exception is thrown when the ComboBox already has some selection and then it is data bound to a data source, which does not contain an entity with the same value.
If you simply set the SelectedValue in a Button's Click event handler as you have suggested, the selection will be reset without the exception.
Kind regards,
Simon
the Telerik team
Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.