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

Image in dropdown (using sample)

3 Answers 126 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 28 Aug 2008, 09:48 PM
What am I missing?

here is my aspx code:

<radC:RadComboBox ID="cboImages" runat="server" Width="150px" DataSourceID="sdsMediaLibrary" SkinsPath="~/RadControls/ComboBox/Skins">
<itemtemplate>
<div>
<img src='../<%# DataBinder.Eval(Container, "Attributes['ImagePath']") %>' alt="" />
</div>
</itemtemplate>
</radC:RadComboBox>

My Code Behind in the ItemDataBound Event:

Dim item As RadComboBoxItem = CType(e.Item, RadComboBoxItem)
Dim row As DataRowView = CType(e.Item.DataItem, DataRowView)
item.Attributes("ImagePath") = row("ThumbUrl")

I checked the ItemDataBound Event and a value is being passed for "ThumbUrl", but when it renders I get:
<div>
       <img src='../' alt="" />
</div>
 and of course the big red X for the image in the dropdown

I have been pouring over the sample code and mine and I just can't seem to figure out what I am missing.

Thanks
    Mike

3 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 29 Aug 2008, 07:03 AM
Hi Michael,

You need to use Container.DataItem since you are in databound mode:

<%# DataBinder.Eval(Container.DataItem"Attributes['ImagePath']") %> 

You can check this help article for more information:
DataBinding expressions

I hope this helps.

Best wishes,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Michael
Top achievements
Rank 1
answered on 29 Aug 2008, 01:04 PM
I changed it to:
<img src='../<%# DataBinder.Eval(Container.DataItem, "Attributes['ImagePath']") %>' alt="" />

Now I get the error:
DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'Attributes'
0
Michael
Top achievements
Rank 1
answered on 29 Aug 2008, 01:17 PM
nevermind,
I didn't need the 'Attibutes" at all.
So much to learn...
Tags
ComboBox
Asked by
Michael
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Michael
Top achievements
Rank 1
Share this question
or