text: Introduction:
  In this article I will explain how to bind images to dropdownlist in asp.net using JQuery.
  In this article I will explain how to bind images to dropdownlist in asp.net using JQuery.
  Description:.
  To implement concept first design table in your database and enter data as shown below
  After completion of table creation enter data in table like as show in below.
  Here I am getting images data from already inserted data if you want to dynamically insert images in database check this post insert images in folder and images path in database.
  Now open Visual Studio and create new website after that right click on your website and add new folder and give name as Images and insert country flag image in that folder you should get it from attached folder.After that write the following code in your aspx page
  If you observe above code in header section I added some of script files and css file by using those files we have a chance to add images in dropdownlist. To get those files download attached sample code and use it in your application.
  After completion of aspx page design add following namespaces in code behind
  C#.NET Code
  After add namespace write the following code
  VB.NET Code
  If you observe above code I am binding title to dropdownlist elements by using BindTitles() method. Here our JQuery plugin will take the title of dropdownlist elements and display the images beside of the text.
  Now run your application and check how your dropdownlist will be
  Demo
  Download sample code attached
  43 comments :
  super interesting. Thanks for sharing
  really nice suresh :), Im also suresh ;)
  Hi Mr. Suresh ,
  I use the custom dropdown v2.37.5 as the following:
  1. I have a table with name COUNTRY with columns [id,countryName,flag].
  2. I have a table with name MFG with columns [id,mfgName,countryID].
  3.I fill the Dropdown as the following:
  [Germany]
  VW
  Mercedes
  BMW
  [Korea]
  Hyundai
  KIA
  and so on.
  What I need to do is how to make the countries items with background color?
  thank you.
  Very very helpful! Really saved my time of work!
  Thak you very much:)
  Alona (Ukraine)
  hi this is deepak garg,
  i have gone through many blogs but your blog has really some different tutorials.
  now i have decided to read your blog regularly.
  pls if u can then also start tutorial which tell how exactly a project should be started with proper SDLC process. that will really help me .......
  this is my email id deepagargak@gmail.com
  thanks
  After running this code on re sizing an image after upload and still retaining the same quality, i got this error.
  error 'System.Web.UI.WebControls.Image' does not contain a definition for 'FromStream'
  Validation Complete
  After running this code on resizing an image after upload i got this error.
  error 'System.Web.UI.WebControls.Image' does not contain a definition for 'FromStream'
  Validation Complete
  Hi!
  really nice article but i am facing problem when using update panel Is there any solution?
  there is no single line of code to bind images.it is not at all working. it is a wrong post.
  @ Comment 9...
  Before give wrong comment check the code i am binding images in code behind. Check it once if it not works means how can i show the demo. Please check thoroughly before give wrong comments...
  man you r d best............
  thnk u...
  Does it work with Masterpages?
  yeah it will work in masterpages also...
  Hi suresh iam using a increment of rows in the html page using javascript with row elements(checkbox,dropdownlist,textarea)in each row
  the problem is how can i bind data from sql server so that dropdownlist of each row should fetch data from database...
  awesome. i need a code to implement the SQL database data with multiple sheets in same excel sheet in c# .net. will you help me
  after executing it shows the msg that "" $("#ddl_Operator").msDropDown() "" is not a function
  plzz help me to solve this problem !!!!
  is there a way to set value for the dropdown box?
  "after executing it shows the msg that "" $("#ddl_Operator").msDropDown() "" is not a function"
  "#ddl_Operator" y0u should replace it with the dropdown ID, i guess that helps
  after executing it shows the msg that "" $("#ddl_Operator").msDropDown() "" is not a function
  help me sir
  country change page refresh.
  i use dropdown list
  in asp update panel flag image not retrive....
  any suggestion how to stop page reload.....
  absolutely working great work thank you..
  Hey When I Created a Insert Option For This Dropdown and allowed user to insert some images with names in to The dropdown the dropdown certainly braking in to two after inserting. and when i refresh then again it is coming in to one is their any solution for this problem.
  Its very userful & interesting article!!
  your code is awesome. It worked for me.
  Now i want to remove scroll from dropdown.
  Please help me out.. Thanks in advance
  This code not work in IE browser. is ther any solution for it. Please help me out. Thanks in advance.
  Is is possible to apply this code for more than 2 dropdown??
  Hi Suresh,
  This code works perfectly.
  How do I change the image size?
  I have some images which are large and some are small. So it makes my ddl look clumpsy and bad.
  Thanks in advance
  where to find javascript files ?
  this is not work with Masterpages
  i want comments coding
  Hello Suresh...U r doing great...m regularly visiting ur site and m fan of you...
  but here when I m using this code in content page..its not work at all...
  I am using master pages and update panel in content page...update panel has asynchronous trigger on save button
  so can you please tell me how to use same code in master page...
  thnx in advance
  DropDownList1.DataSource = ds;
  DropDownList1.DataTextField = "CountryName";
  DropDownList1.DataValueField = "CountryImage";
  DropDownList1.DataBind();
  con.Close();
  foreach (ListItem ListItem in DropDownList1.Items)
  {
  ListItem.Attributes["title"] = "CountryImages/" + ListItem.Value;
  }
  hi suresh,
  i am using no sql database(couchdb).i have list of item name and list of image path.so whenever i am giving imagepath in DropDownList1.DataValueField , it gives error.please help me,my mail id is shekharchauhan91@gmail.com
  $(document).ready(function (e) {
  try {
  $("#MainContent_FormItem_3_3").msDropdown();
  } catch (e) {
  alert(e.message);
  }
  });
  when i am using above code.this gives alert 'undefined is not a function'.
  that is why i am not able to bind image in dropdownlist control.
  please help.
  $(document).ready(function (e) {
  try {
  $("#MainContent_FormItem_3_3").msDropdown();
  } catch (e) {
  alert(e.message);
  }
  });
  this jquery is giving alert message in mozila:
  '$(...).msDropdown is not a function'
  Can this work inside GridView?
  I have put DropdownList in GridView control, but its not working correctly
  Here's the code to find ID
  $(document).ready(function (e) {
  $('#<%=GridProcessFlow.ClientID %>').find('span[id$="ddlLegends"]').msDropDown();
  });
  Its finding the control, filling the name but not images. i guess it's not able to apply CSS.
  not working sir
  Hi suresh
  its working absolutely fine but i can't get the value of drop down and i cant set the particular value in drop down is there any solution then please help me
  Hello sir
  its working fine on master page too
  but giving alert as
  "arrow is undefined"
  can u please help me out of this
  thanx in advance :)
  plz help
  giving alert
  $(...).msDropDown is not a function
  its good article and it is working fine in all the browsers.