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

Items bound twice when AppendDataBoundItems = True

1 Answer 115 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Stewart Partington
Top achievements
Rank 1
Stewart Partington asked on 23 Jul 2008, 03:18 PM
Hello,

I'm using the Q1 / 2008 version of the rad combo box.

When I bind my combo box, I set AppendDataBoundItems = True because I want to insert an item with "-- Please Select --". Here is the code:

Dim strSelect As String

Dim dr As DataRow

Dim objDictionary As Dictionary

strSelect =

"-- Please Select --"

objDDL.DataSource = dt

objDDL.DataTextField = strText

objDDL.DataValueField = strValue

objDDL.DataBind()

Dim objDDLItem As Telerik.WebControls.RadComboBoxItem = New Telerik.WebControls.RadComboBoxItem("-- " & objDictionary.GetLabel(Labels.PLEASESELECT) & " --", "-1")

objDDL.AppendDataBoundItems =

True

objDDL.Items.Insert(0, objDDLItem)

As a result, I get the items duplicated (1 list of items, then the other). I've noticed that the .DataBound event fires twice for the combo box. When I view the Call Stack for the second .DataBound event, there is no source for the call.

If I set AppendDataBoundItems = false, then the .DataBound event only gets fired once, and I only have 1 list of items. However, I do not get the "-- Please Select --" item added.

I've also tried to add the "-- Please Select --" item to the combo box (as in numerous examples), but I still get the same results.

Thanks!

1 Answer, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 24 Jul 2008, 07:21 AM
Hi Stewart ,

Please find the attached sample project illustrating that everything works as expected at our side. You can download it and find the differences at your side.

Regards,
Rosi
the Telerik team

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