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

RadListbox Image URL

1 Answer 185 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Anirudh
Top achievements
Rank 1
Anirudh asked on 26 Aug 2016, 08:59 PM

I have tied the items text to list box using server side programming. I want to bind the ImageURL for the list items in the Radlistbox also programmatic ally but I dont see the ImageURL property in the list of listbox properties or the properties of the item.

I know there is a we have a HTML property something like this ImageUrl ="../App_Themes/Default/Images/

I am not using the listboxitems tag here and so   can not use ImageUrl ="../App_Themes/Default/Images/. Is there any way i can use the server side programming to bing the image to the text items?

 

            <tlr:RadListBox RenderMode="Lightweight" runat="server" ID="RadListBoxSource" Height="165px" Width="100px"
            AllowTransfer="true" TransferToID="RadListBox1"
            ButtonSettings-AreaWidth="30px"  >
        </tlr:RadListBox>     
        <tlr:RadListBox RenderMode="Lightweight" runat="server" ID="RadListBox1" Height="165px" Width="100px"
            ButtonSettings-AreaWidth="35px" AllowReorder="true" >
        </tlr:RadListBox>

1 Answer, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 31 Aug 2016, 11:04 AM
Hello Anirudh,

There is no DataImageUrl property that would allow images to be bound to items. However, you can set the items' ImageUrl property in the code-behind, for example in the ListBox' ItemDataBound event. When the ListBox is loaded with items from the data source this event will fire for each item and you can get information about the item through the event's arguments (for instance e.Item.Text or e.Item.Value). Here's an example that sets the ImageUrl property of an item with text "Tokyo":
protected void RadListBoxSource_ItemDataBound(object sender, RadListBoxItemEventArgs e)
{
    if (e.Item.Text == "Tokyo")
    {
        e.Item.ImageUrl = "images/Tokyo.png";
    }
}


Regards,
Ivan Danchev
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
ListBox
Asked by
Anirudh
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Share this question
or