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

Problem with DataBound

3 Answers 72 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 01 Aug 2008, 02:43 PM
I have 5 RadComboBoxes (RCB) that are set to AutoPostBack and are all tied to individual ObjectDataSources.  I have subroutines for each SelectedIndexChanged that will bind the next RCB to it's ObjectDataSource.  I also have subroutines for each DataBound that will a) automatically select option #2 if there are only 2 options, and b) call the SelectedIndexChanged for the RCB so the next RCB can be bound to its data.

The process goes like this:  the first RCB is bound and the other 4 are disabled.  When the user select from the first RCB, it's posted back and the second RCB is filled.  The user then selects from the second RCB and after postback the third RCB is filled.  The user then selects from the third RCB and now the fourth RCB is filled.  Hoever, at this point the code looks and notices that there are only 2 options, so it selects the 2nd and calls the SelectedIndexChanged (as if the user clicked it) and fills the 5th RCB.

What I get in the end is twice as much data in the 5th RCB as expected.  For example, if the ObjectDataSource really returns 1 result, I see 2 options in the 5th RCB.  And if it returns 2 results, I see 4 options in the RCB.

I can place breakpoints on the DataBound and SelectedIndexChanged and I notice that the DataBound subroutine gets hit twice...the second time for no apparent reason.

I added some debugging code in RCB5.ItemCreated and found that if the ObjectDataSource returned 3 items, this subroutine would only be hit twice.  Likewise if it returned 2 times, this subroutine would only be hit once.

Can anyone shed some light on this?  If I need to clarify anything please let me know.

Thanks!

3 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 04 Aug 2008, 11:55 AM
Hi Bob,

Have you set the AppendDataBoundItems of the last RadComboBox to true? If this property is not set, upon re-binding the control the previously loaded Items will be cleared.

Please verify this and let me know whether is so.

Greetings,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Bob
Top achievements
Rank 1
answered on 04 Aug 2008, 01:00 PM
Yes, I do have that property set on all 5 ComboBoxes.

 <telerik:RadComboBox ID="ddlTab1Engine" Runat="server"
                                    AllowCustomText="false"
                                    AppendDataBoundItems="true"
                                    AutoPostBack="true"
                                    CssClass="ddlRCB"
                                    Enabled="false"
                                    EnableEmbeddedSkins="false"
                                    MarkFirstMatch="true"
                                    Skin="Skin_Custom0001"
                                    Tooltip="Select an Engine"
                                    Width="200"
                                    >
                                  <ExpandAnimation Duration="300" Type="OutQuint" />
                                  <CollapseAnimation Duration="200" Type="InQuint" />
                            </telerik:RadComboBox>
0
Simon
Telerik team
answered on 05 Aug 2008, 10:21 AM
Hi Bob,

Thank you for the additional info.

If the AppendDataBoundItems property is set to true, when the RadComboBox control is bound a second time, the previously loaded Items will not be cleared, hence there will be two sets of Items

Since in your case, the control is bound twice, it is normal to have doubled Items (binding to the same datasource twice). So, setting AppendDataBoundItems to false will 'resolve' the problem but only on the surface - the control will still be bound twice.

However, why this is happening can hardly be determined without first examining the code. In this sense, I suggest you open a formal support ticket and send us a page or a subset of your project files exhibiting the problem, so that we can examine them.

Regards,
Simon
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Bob
Top achievements
Rank 1
Answers by
Simon
Telerik team
Bob
Top achievements
Rank 1
Share this question
or