User Control in RadComboBox

4 posts, 0 answers
  1. Jean-Marc
    Jean-Marc avatar
    93 posts
    Member since:
    Mar 2011

    Posted 08 Sep 2011 Link to this post

    Can I place a User Control inside a RadComboBox?
    Something like this:
     
    <telerik:RadComboBox ID="RadComboBoxCategoryLevels"
    Width="400px"
    AllowCustomText="false"
    runat="server" >
    <ItemTemplate >
    <qsf:Catrunat="server" ID="MYCat" ></qsf:Cat>
    </ItemTemplate>
    <Items>
    <telerik:RadComboBoxItem Text="" />
    </Items>
    </telerik:RadComboBox>

     

    I tried, but it does not work, Thanks


  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 08 Sep 2011 Link to this post

    Hello Jean,

    Here is the code I tried that worked as expected.
    aspx:
    <telerik:RadComboBox ID="RadComboBox1" Filter="Contains" AllowCustomText="true" AppendDataBoundItems="true" runat="server" >
      <ItemTemplate>
         <uc1:uclistBox ID="uclistBox1" runat="server" />
         <%# DataBinder.Eval(Container, "Text") %>
      </ItemTemplate>
      <Items>
        <telerik:RadComboBoxItem Value="10/10/2010" Text="10/10/2010" />
        <telerik:RadComboBoxItem Value="10/3/2010" Text="10/3/2010" />
        <telerik:RadComboBoxItem Value="10/10/2010" Text="10/10/2010" />
        <telerik:RadComboBoxItem Text="Date1" IsSeparator="true" />
      </Items>
    </telerik:RadComboBox>

    Before the template can use the combobox item properties to bind the elements in the template, the application needs to explicitly bind the items by calling the DataBind method of the RadComboBoxItem objects:
    C#:
    protected void Page_Load(object sender, EventArgs e)
       {
           for (int i = 0; i < RadComboBox1.Items.Count; i++)
           {
               RadComboBox1.Items[i].DataBind();
           }
       }

    Thanks,
    Princy.
  3. Jean-Marc
    Jean-Marc avatar
    93 posts
    Member since:
    Mar 2011

    Posted 09 Sep 2011 Link to this post

    Thanks, now everything works.
    another question.
    in my user control I have a RadTreeView, with properties and events to which I can not see just because the tree is located within the ComboBox.
    there is a way to fix this?
    thanks
  4. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1268 posts

    Posted 13 Sep 2011 Link to this post

    Hi Jean-Marc,

    I've prepared a sample page based on the scenario that you have explained.

    I hope this would help you out.

    Best wishes,
    Dimitar Terziev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top