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

Item Template Databind Issue

5 Answers 307 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
nad
Top achievements
Rank 1
nad asked on 13 Feb 2008, 01:59 AM
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>

5 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 13 Feb 2008, 11:43 AM
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
0
Skywalker
Top achievements
Rank 1
answered on 04 Mar 2008, 07:58 PM
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?
0
Veselin Vasilev
Telerik team
answered on 07 Mar 2008, 10:04 AM
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
0
Andrew
Top achievements
Rank 1
answered on 22 Oct 2008, 03:42 PM
Hi, is there a way to do this same databinding for a control that is created at runtime?
0
Veselin Vasilev
Telerik team
answered on 24 Oct 2008, 02:42 PM
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.
Tags
ComboBox
Asked by
nad
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Skywalker
Top achievements
Rank 1
Andrew
Top achievements
Rank 1
Share this question
or