Combobox itemtemplate not selectng values

3 posts, 1 answers
  1. Perico
    Perico avatar
    2 posts
    Member since:
    Nov 2011

    Posted 22 Nov 2011 Link to this post

    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. Answer
    Bozhidar
    Admin
    Bozhidar avatar
    1192 posts

    Posted 22 Nov 2011 Link to this post

    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
  3. Perico
    Perico avatar
    2 posts
    Member since:
    Nov 2011

    Posted 22 Nov 2011 Link to this post

    Thanks Bozhidar!! Thats was easy!
Back to Top