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

http://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:16pm
v2

1 solution

Read data into list like

C#
class country
{
public string id{get; set;}
public string name{get; set;}
}


for DB we will access names and code push thos values into a list
C#
List<country> l=new List<country>();
country c=null;
c=new country();
c.id="1";
c.name="india";
l.add(c);
c=new country();
c.id="2";
c.name="srilanka";
l.add(c);</country></country>


where you are writing drop down use like this

C#
<![CDATA[<%foreach(country c in l)
{%>]]>
<a href="<%=c.id%>">,%=c.name%></a>
<![CDATA[<%}%>]]>
 
Share this answer
 
Comments
Reyhaneh63 30-Dec-11 13:29pm    
Thanks for your answer, but it doesn't work for me. can you explain more about it ? specilay about xml section.

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