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

[Solved] Programatic creation of headertemplate

3 Answers 76 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 18 Sep 2009, 09:52 AM
Hi - how do I programmatically add a header template and item template to a combo box?

Thanks

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 18 Sep 2009, 10:07 AM
Hello John,

Please check this and this.

All the best,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
John
Top achievements
Rank 1
answered on 18 Sep 2009, 01:33 PM
Thanks - I got that working but had to change it to:

 

string itemText = (string)DataBinder.Eval(item.DataItem, "Town")+ " - " + (string)DataBinder.Eval(item.DataItem, "StateName");

 


As I was using a datatable.

Thing is, now when I hover over the options, it doesn't highlight them (as they are lables I suppose) but also, when I select one, the value in the box changes to:

System.Data.DataRowView

Rather than the value I selected.

Any idea why?

All I really wanted to do was display two values from my datatable as the text in the dropdown - so, I have 2 columns - Town and StateName and I want the display to show something like 'Abbyville - Kansas'

Am I using the correct approach? And, if I am, how do I solve the System.Data.DataRowView issue?

Thanks
0
Yana
Telerik team
answered on 18 Sep 2009, 01:46 PM
Hello John,

Please set HighlightTemplatedItems property to true and the items will be highlighted.

Regarding the second issue, you should set Text property of the items, because Text is shown in the input field of the combobox when they are selected. You can set it in OnItemDataBound event handler.

All the best,
Yana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
ComboBox
Asked by
John
Top achievements
Rank 1
Answers by
Yana
Telerik team
John
Top achievements
Rank 1
Share this question
or