Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello everyone
i wrote a custom control (DropDownList) from here

www.afekenholm.se/scrollectbox-jquery-plugin[^]

As you see , the items fill with manual data like " option 1" ,"option 2" ,...
Now i want to fill this control from a generic list or database like sql.
How can i do this?
Best regards.
Posted
Updated 29-Dec-11 19:45pm
v3

1 solution

Hi,

Here i given sample please verify this!

C#
string PATH2 = AppDomain.CurrentDomain.BaseDirectory + "Files";

          List<ListItem> directorystruct = new List<ListItem>();
           int i=1;
       foreach (string d in Directory.GetDirectories(PATH2))
       {
    string items = "Item " + i;
   directorystruct.Add(new ListItem(d, items));
   i++;
   }
ddlselect.Items.Insert(0, "--Select--");
ddlselect.Items.AddRange(directorystruct.ToArray());



I gets the files from directory and putting in to dropdownlist!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900