Databinding an image inside of a RadComboBox

6 posts, 0 answers
  1. Randy
    Randy avatar
    73 posts
    Member since:
    Oct 2007

    Posted 03 Oct 2008 Link to this post

    I noticed that the RadComboBoxItem class has an ImageUrl property but there doesnt seem to be a binding property on the main combo to allow for databinding for property.    Seems to me that have a RadComboBox.DataImageUrl field would be nice on the main combo.  

    Do I need to create a templated item in order to do this?

    Thanks
  2. Serrin
    Serrin avatar
    286 posts
    Member since:
    Sep 2008

    Posted 03 Oct 2008 Link to this post

    Hey Randy,

    You can see this demonstrated in the First Look application as well as an example in the Custom Attributes for ComboBox online demo.  Look at the code for the Avatar dropdown section and you can see DataBinder.Eval being used to put images into the template.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Randy
    Randy avatar
    73 posts
    Member since:
    Oct 2007

    Posted 03 Oct 2008 Link to this post

    Yes.  I saw that example.  My question was whether or not there is a building mechnism that allows you to tap into the RadComboBoxItem.ImageUrl property without having to revert to a templated item.  It is a little more work to create a template rather than a simple DataBind.

  5. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 06 Oct 2008 Link to this post

    Hi Randy,

    You can bind any additional properties (like ImageUrl) in the ItemDataBound event.

    I hope this helps.

    Sincerely yours,
    Veskoni
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. peter
    peter avatar
    6 posts
    Member since:
    Jun 2007

    Posted 22 May 2009 Link to this post

    I am binding a Combo box to a object datasource on my page

     

     

    <asp:ObjectDataSource runat="server" ID="odsLanguage" TypeName="Gottmi.Web.Helpers.LanguageHelper"

     

     

     

    SelectMethod="List"

     

     

     

    DataObjectTypeName="Gottmi.DLL.Language"

     

     

     

    CacheDuration="360"

     

     

     

    CacheExpirationPolicy="Sliding"

     

     

     

    EnableCaching="true"></asp:ObjectDataSource>

     

    protected void ddlLanguage_OnItemDataBound(object sender, Telerik.Web.UI.RadComboBoxItemEventArgs e)

     

    {

     

     

    Gottmi.DLL.Language language = (Gottmi.DLL.Language)e.Item.DataItem;

     

     

     

    if (language != null && !string.IsNullOrEmpty(language.ImageUrl))

     

    {

     

     

    e.Item.ImageUrl = language.ImageUrl;

     

    }

    }


    I then use the OnItemDataBound event to set the image url. The url for the image is in my datasource. The image is not displayed when the page renders. The URL is correct as I use it with the toolbar control on my menu and this works perfectly. I am using the latest download css and DLL.

    Any ideas ?

    tks H

     

     


     

  7. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 25 May 2009 Link to this post

    Hello peter,

    Can you please check what is the full path of the image that is being rendered for every item and see if those files exist.


    Kind regards,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017