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

RadComboBox + ItemTemplate + Databind

6 Answers 791 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Philip
Top achievements
Rank 1
Philip asked on 07 Mar 2008, 08:41 AM
Hello,

I'm using the newest Prometheus version  2007.3 1425.

Using the example from the documentation does not work.

<telerik:RadComboBox ID="RadComboBox2" runat="server" Height="190px" Width="350px"
    <ItemTemplate> 
        <table> 
            <tr> 
                <td> 
                    Test 
                </td> 
                <td> 
                    <%# DataBinder.Eval(Container.DataItem, "Text")%> 
                </td> 
            </tr> 
        </table> 
    </ItemTemplate> 
    <Items> 
        <telerik:RadComboBoxItem 
            Text="Winter"
        </telerik:RadComboBoxItem> 
        <telerik:RadComboBoxItem 
            Text="Fall"
        </telerik:RadComboBoxItem> 
    </Items> 
</telerik:RadComboBox>   

The textfield ist not displayed in the dropdown. What do I wrong?

Thanks and kind regards,

Phil

6 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 07 Mar 2008, 09:46 AM
Hi Philip,

Since you are in Unbound mode you need to call the Eval method in the following way:

<%# DataBinder.Eval(Container, "Text")%> instead of <%# DataBinder.Eval(Container.DataItem, "Text")%>

You can find more information here: Controls > RadComboBox > Templates > Data Binding in Templates

I hope this helps.

Kind regards,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Philip
Top achievements
Rank 1
answered on 07 Mar 2008, 10:10 AM
Hi,

thank you, for this incredible fast answer. In my first attempts I used only Container, without DataItem. This even didn't work in my posted example.

Even if I copy and paste the first example on Controls > RadComboBox > Templates > Templates Overview it doesn't work.
0
Veselin Vasilev
Telerik team
answered on 07 Mar 2008, 11:03 AM
Hello Philip,

Did you DataBind() the combobox in the Page_Load event?

protected void Page_Load(object sender, EventArgs e)  
{  
    RadComboBox2.DataBind();  


Sincerely yours,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Philip
Top achievements
Rank 1
answered on 07 Mar 2008, 12:17 PM
Hi!

No, there is no databinding in my Page_Load Event.

Is it necessary to databind the combobox even when I fill the combobox only staticly per ASP?

0
Accepted
Veselin Vasilev
Telerik team
answered on 07 Mar 2008, 12:39 PM
Hello Philip,

Yes, it is necessary. Here is an extract from the online help article I pointed out:

In addition to adding a DataBinder.Eval statement, you must also explicitly call the DataBind method for the items so that the template has access to the Text property.

All the best,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Philip
Top achievements
Rank 1
answered on 08 Mar 2008, 12:55 PM
Ok, I will try this.

Thank you for your continuos fast answers.

Philip
Tags
ComboBox
Asked by
Philip
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Philip
Top achievements
Rank 1
Share this question
or