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

Combobox with template

5 Answers 93 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Blop
Top achievements
Rank 1
Blop asked on 25 Apr 2012, 02:52 PM
Hello. I've a little issue to get the combobox as I want it to be.
I have, in a database, a table "colors" (let say it only has an "ID" and "code" fields). I want to populate a radcombobox with a small square of each color.

Here's what I do:

<telerik:RadComboBox ID="rcbProdColors" Width="60" runat="server" MarkFirstMatch="false"  AllowCustomText="false" DataValueField="ID" >
              <ItemTemplate>
                     <div style=" height:15px;width:15px;border:solid black 1px;background-color: #<%# Eval("Code")%>"></div>                                
            </ItemTemplate>                      
</telerik:RadComboBox>

And in the code behind:

Dim query = (From c In db.Colors Select c)
rcbProdColors.DataSource = query
rcbProdColors.DataBind()

It's working but not completly.
I have two main issues:

First: The first "item" of the combobox isnt a color square but text saying "colors". I dont know where it comes from, my guess is it is the name of the table in the database. How can I remove it and have a color square as first item?

Second: More important: I can't select anything... whatever my choice, the selected item will always be the first item (in this case the text "colors"). How can I make a selection on this combobox?

Thanx in advance for yours answers.

5 Answers, 1 is accepted

Sort by
0
Blop
Top achievements
Rank 1
answered on 26 Apr 2012, 10:17 AM
No one to help me out?
0
Cat Cheshire
Top achievements
Rank 1
answered on 26 Apr 2012, 12:17 PM
0
Blop
Top achievements
Rank 1
answered on 26 Apr 2012, 01:03 PM
Well thanks but it's almost the same things I do... I don't understand why can't I select an Item and why there's a first item created wich has nothing to do there...
0
Blop
Top achievements
Rank 1
answered on 27 Apr 2012, 03:21 PM
Anyone hanging out here?
0
Ivana
Telerik team
answered on 01 May 2012, 02:39 PM
Hi,

Try to specify the DataTextField and DataValueField when databinding the RadComboBox:
http://www.telerik.com/help/aspnet-ajax/combobox-data-binding-datatable-set-view.html.

All the best,
Ivana
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ComboBox
Asked by
Blop
Top achievements
Rank 1
Answers by
Blop
Top achievements
Rank 1
Cat Cheshire
Top achievements
Rank 1
Ivana
Telerik team
Share this question
or