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

Combobox itemtemplate not selectng values

2 Answers 49 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Perico
Top achievements
Rank 1
Perico asked on 22 Nov 2011, 09:48 AM
Hi,

I have a radcombobox declared like this:
<telerik:RadComboBox ID="RadComboBox1" Runat="server" Width="300"
    AppendDataBoundItems="True">
    <ItemTemplate>
        <div class="item c1"><asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("URLImage") %>' /></div>
        <div class="item c2"><%# Eval("Imagename") %></div>
    </ItemTemplate>
</telerik:RadComboBox>

 and I'm populating whith this code:

RadComboBox1.DataSource = getimages()
Function getimages() As List(Of Fotos)
    Dim ofile, foto
    Dim ObjetoFSO = Server.CreateObject("Scripting.FileSystemObject")
    Dim ObjetoFolder = ObjetoFSO.GetFolder(Server.MapPath("../images/works"))
    Dim ofotos = New List(Of Fotos)
 
    For Each ofile In ObjetoFolder.Files
        foto = New Fotos()
        foto.Imagename = fichero.name
        foto.URLImage = ResolveUrl("~/Images/works/thumbs/" & ofile.name)
        ofotos.Add(foto)
    Next
 
      file= Nothing
    ObjetoFolder = Nothing
    ObjetoFSO = Nothing
 
    Return ofotos
End Function
Everything seems to be allright butI'm unable to select an item . The dropdown show the elements but in the displayed text I always have:
"SampleProject.WebForm13+Fotos"

Am I doing something wrong? Where is my mistake?

Thanks!

2 Answers, 1 is accepted

Sort by
0
Accepted
Bozhidar
Telerik team
answered on 22 Nov 2011, 12:23 PM
Hi Perico,

You have to add the DataTextField and DataValueField properties to the RadComboBox. For your example if you want the displayed text to be the file name, you should write the following:
<telerik:RadComboBox ID="RadComboBox1" Runat="server" Width="300"
    DataTextField="Imagename"
    AppendDataBoundItems="True">

Regards,
Bozhidar
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
0
Perico
Top achievements
Rank 1
answered on 22 Nov 2011, 03:02 PM
Thanks Bozhidar!! Thats was easy!
Tags
ComboBox
Asked by
Perico
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Perico
Top achievements
Rank 1
Share this question
or