Need help with ComboBox ItemTemplates

2 posts, 0 answers
  1. fred williams
    fred williams avatar
    55 posts
    Member since:
    Feb 2010

    Posted 10 Nov 2010 Link to this post

    So I’m using the directoryinfo class to obtain the filenames from a network share, and then display them into my radcombobox. Everything works fine, but what I’d like to do is create a checkbox next to all of the values in the combobox so the user can select multiple files.

    When I do it without the itemtemplate, all the filenames display fine, but when I try to use them to add the checkbox, the checkboxes show up but the filenames don’t. Here’s what I have:

    <telerik:RadComboBox ID="cboFiles" runat="server" AutoPostBack="true" Width="350px" OnItemDataBound="cboFilesDBound">
             <asp:CheckBox ID="chkFile" runat="server" /> 
    What do I need to put next to the checkbox to get the filenames to display? Again, when I do this without the template the filenames show fine. I tried using databinder.eval with some custom attributes like the demo, but it didn't work.

    Here's the codebehind:
    protected void setDirectory(String path)
        RadComboBox cb = (RadComboBox)FindControl("cboFiles");
        DirectoryInfo di = new DirectoryInfo(path);
        FileInfo[] files = di.GetFiles();
        foreach (FileInfo f in files)
            RadComboBoxItem item = new RadComboBoxItem(f.Name, f.Name);
            item.Attributes["displayName"] = f.Name;

  2. Simon
    Simon avatar
    2281 posts

    Posted 16 Nov 2010 Link to this post

    Hi fred williams,

    You need to use data binding expressions inside the ItemTemplate definition to render the additional data as done in the first RadComboBox in this demo.

    I hope this helps.

    All the best,
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top