Item Template Databind Issue

6 posts, 0 answers
  1. nad
    nad avatar
    7 posts
    Member since:
    Oct 2007

    Posted 12 Feb 2008 Link to this post

    Hi,
    Im trying to build a combo box that will allow multiple selections. My issue is that when i build the checkboxes i can't get to bind text against each checkbox. it comes up empty. is this the correct way to achieve what i want ?
    Thanks

     <radc:RadComboBox runat="server" ID="RadComboBox1" HighlightTemplatedItems="true" >
                    <Items>
                        <radc:RadComboBoxItem Text="One" Value="1"  />
                        <radc:RadComboBoxItem Text="Two" Value="2"/>
                        <radc:RadComboBoxItem Text="Three" Value="3"/>
                    </Items>
                    <ItemTemplate>
                        <asp:CheckBox runat="server" ID="CheckBox"  Text=""/>
                        <span><%# DataBinder.Eval(Container, "Text") %></span>
                    </ItemTemplate>
      </radc:RadComboBox>
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 13 Feb 2008 Link to this post

    Hello nadeetha,

    You need to call the DataBind() of the RadComboBox in your Page_Load event.

    RadComboBox1.DataBind(); 

    I hope this helps.

    Best wishes,
    Veskoni
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Skywalker
    Skywalker avatar
    67 posts
    Member since:
    Sep 2007

    Posted 04 Mar 2008 Link to this post

    I was having the same problem with Databinding inside a Template. Calling the DataBind method on the RadComboBox instance in the OnLoad event of the page (or UserControl) works indeed. Is it also possible to use the new ASP.NET "Bind" syntax? I tried this:

    <telerik:radcombobox id="myList" runat="server" skin="Telerik">
       <itemtemplate>
          <asp:label runat="server" id="itemText" text='<%#Bind("Text") %>'></asp:label>
       </itemtemplate>
       <items>
          <telerik:radcomboboxitem Text="Item 1" />
          <telerik:radcomboboxitem Text="Item 2" />
          <telerik:radcomboboxitem Text="Item 3" />
       </items>
    </telerik:radcombobox>

    But it's not working; all rendered <li> items are empty. Am I doing it wrong?
  5. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 07 Mar 2008 Link to this post

    Hello Sipke,

    For the Prometheus controls you need to use DataBinder.Eval method.

    This is described here: Controls > RadComboBox > Templates > Data Binding in Templates

    I hope this helps.

    Greetings,
    Veskoni
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Andrew
    Andrew avatar
    104 posts
    Member since:
    May 2008

    Posted 22 Oct 2008 Link to this post

    Hi, is there a way to do this same databinding for a control that is created at runtime?
  7. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 24 Oct 2008 Link to this post

    Hello Andrew,

    You can create Templates at Runtime as well. Please check this article:
    Adding Templates

    Regards,
    Veselin Vasilev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017