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

How to add images to a combobox used as a filter

1 Answer 48 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 07 Jun 2011, 12:21 PM
Hi

I am using a combobox in my filter template and want to add icons to the items in the drop down list.

I have seen how to do this declaritively in the aspx definition, but I don't want to have a fixed list
in the page. I would rather load it programatically.I have already created a datasource
that I am using, but there appears to be no way of indicating the field to use for ItemUrl.

This might be a really nice feature.

Another approach I was trying to pursue would have me loading the combobox items during page load.
How do I access the appropriate combobox within my grid control. There is no corresponding item in the 
designer cs file. Presumably I can access the combobox from the grid's control list, but I am unclear on how to 
do this.

TIA 

1 Answer, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 10 Jun 2011, 09:54 AM
Hi Tim,

If you want to add images to the items of the RadCombobox, when its bound to a data source, you should use the ItemDataBound server side event and add the corresponding image in the ImageUrl property of the item.

The event handler function should be something like this:
protected void RadComboBox1_ItemDataBound(object o, RadComboBoxItemEventArgs e)
{
    DataRowView dataSourceRow = (DataRowView)e.Item.DataItem;
    //set image url from the datasource: 
    e.Item.ImageUrl = dataSourceRow["ImageUrl"].ToString();      
}

Please refer to the following help article on how to reference controls in the RadGrid.

I hope this would help you out.

Regards,
Dimitar Terziev
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
ComboBox
Asked by
Tim
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or