How to add images to a combobox used as a filter

2 posts, 0 answers
  1. Tim
    Tim avatar
    57 posts
    Member since:
    Apr 2011

    Posted 07 Jun 2011 Link to this post

    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 
  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1268 posts

    Posted 10 Jun 2011 Link to this post

    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.

Back to Top