Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 16, 2012 08:37 AM by asteranup
Nov 12, 2012 06:44 PM|LINK
Does anybody knows how to solve the following code? I need to load the image in de dropdown from a table and not from a folder.
here is my code
protected void BindTitles()
if (ddlCountry != null)
foreach (ListItem li in ddlCountry.Items)
li.Attributes["title"] = "Images/" + li.Text + ".png";
// Here i need to bind the image to the dropdown list...is it possible to do this in the BindDropDownList()? If so How?
/// Bind Dropdownlist Data
protected void BindDropDownList()
SqlConnection con = new SqlConnection("MyConn");
SqlCommand cmd = new SqlCommand("select * from LoadImage", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
ddlCountry.DataTextField = "img_name";
ddlCountry.DataValueField = "img_image";
ddlCountry.DataSource = ds;
Nov 15, 2012 12:53 AM|LINK
you can't bind image in dorpdownlist, however one alternative could be to use jQuery for this. There's a nice plugin called ImageDropDown that does what you need.
hope this helps, thanks.
Nov 15, 2012 09:11 AM|LINK
You can try msdropdownlist-
Nov 16, 2012 08:29 AM|LINK
Hi Yanping & Asteranup,
I`m using j-query plugin for this...there are two problems with using this..
1. i need to load the images from a sql db into a dropdownlist(asp), normaly i can bind the image to the dropdownlist true refering the title as tooltip to the image path(li.Attributes["title"] = "Images/" + li.Text + ".png";
) bud because the value is comming directly from a database there is no path to bind, if we are talking abouth 10 images or so, then i would save the images in a temp folder, bud because we talking abouth 300 to 400 images this is not a option...so I hope
somebody knows a good work arround for this?
2. When i load the jquery image dropdownlist in a default.aspx(with no master page attached) everything works fine(If i load the images from a folder). Bud when i want to load the imagedropdown in a master page, it doesn`t load the the images(the text is
loaded)..does somebody has knowledge of this issue? and knows a workarround?
Nov 16, 2012 08:37 AM|LINK
For first problem what you can do is use for loop and add item to the dropdownlist instead of using datasource and bind method. This way you will be able to loadd as many item to the dropdownlist option.
Second is a file reference issue. You can check the following post for an explanation-