Showing sample images insted of text in combobox

2 posts, 0 answers
  1. Barbaros Saglamtimur
    Barbaros Saglamtimur avatar
    110 posts
    Member since:
    Jul 2012

    Posted 07 Jul 2009 Link to this post


    Actually I did it but wonder if there is another way. Here is my code. Any improvements are appreciated.

            protected void RadSkinManager1_PreRender(object sender, EventArgs e) 
                DataTable table = new DataTable(); 
                DataRow row; 
                row = table.NewRow(); 
                row.ItemArray = new string[] { "images/default.gif""Default""Default" }; 
                row = table.NewRow(); 
                row.ItemArray = new string[] { "images/black.gif""Black""Black" }; 
                row = table.NewRow(); 
                row.ItemArray = new string[] { "images/forest.gif""Forest""Forest" }; 
                RadComboBox skinChooser = RadSkinManager1.FindControl("SkinChooser"as RadComboBox; 
                skinChooser.DataSource = table; 
                skinChooser.ItemTemplate = new IMGTemplate("ImgUrl"); 
                skinChooser.DataTextField = "txt"
                skinChooser.DataValueField = "val"
                skinChooser.Width = 240; 
                skinChooser.Height = 202; 
                skinChooser.SelectedValue = RadSkinManager1.Skin; 

    class IMGTemplate : ITemplate 
         string pathColumn; 
         public IMGTemplate(string imgPathColumn) 
                pathColumn = imgPathColumn; 
            public void InstantiateIn(Control c) 
                Image imgt = new Image(); 
                imgt.DataBinding += new EventHandler(imgDataBinding); 
            void imgDataBinding(object sender, EventArgs e) 
                Image img_ = (Image)sender; 
                RadComboBoxItem item = (RadComboBoxItem)img_.BindingContainer; 
                DataRowView drv = ((DataRowView)item.DataItem); 
                img_.ImageUrl = drv[pathColumn].ToString(); 
  2. Sebastian
    Sebastian avatar
    9934 posts

    Posted 07 Jul 2009 Link to this post

    Hello barbaros,

    Thank you for posting your solution in our public RadSkinManager forum - thus you can help other people who look for a similar implementation. I updated your Telerik points for the involvement.

    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.
  3. Telerik UI for ASP.NET Core is out
Back to Top