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

[Solved] Change Items inside RadComboBox

1 Answer 174 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ban
Top achievements
Rank 1
Ban asked on 04 May 2009, 08:55 AM
Hi,
I have ComboBox and I used "ItemTemplate" to fill it with my data which is (Picture & Text for each item) and I need to change the Picture for some items inside this Combo during the Run Time , is it possible and how can reach the picturse path inside the items to change it in code behind ? Please Help me with this.
Thanks

Ban

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 May 2009, 09:26 AM
Hello Ban,

Try the following code snippet to access the image control and change the ImageUrl to desired.

ASPX:
 
<telerik:RadComboBox ID="RadComboBox1" DataSourceID="SqlDataSource1" DataTextField="CategoryID" DataValueField="CategoryID" runat="server" HighlightTemplatedItems="True"
<Items> 
    <telerik:RadComboBoxItem runat="server" /> 
</Items> 
<ItemTemplate> 
    <asp:Image ID="Image" runat="server" ImageUrl="~/Images/Image1.gif" />     
</ItemTemplate> 
</telerik:RadComboBox> 

CS:
 
protected void Button1_Click(object sender, EventArgs e) 
    RadComboBoxItem item = (RadComboBoxItem) RadComboBox1.FindItemByValue("1"); // Get the RadComboBox item 
    Image img = (Image)item.FindControl("Image"); // Get the Image control 
    img.ImageUrl = "~/Images/Image2.gif";  //Change the ImageUrl 

Go through the following link for more details:
Finding an item in template

Thanks,
Shinu.
Tags
ComboBox
Asked by
Ban
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or