从数据库或常规列表中的自定义控件(DropDownList)中填充数据 [英] Fill data from database or generic list in a custom control (DropDownList)
本文介绍了从数据库或常规列表中的自定义控件(DropDownList)中填充数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
我从这里编写了一个自定义控件(DropDownList)
http://www.afekenholm.se/scrollectbox-jquery-plugin [
现在,我想从通用列表或类似sql的数据库中填充此控件.
我该怎么办?
最好的问候.
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.
推荐答案
将数据读取到类似
的列表中
Read data into list like
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
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
<![CDATA[<%foreach(country c in l)
{%>]]>
<a href="<%=c.id%>">,%=c.name%></a>
<![CDATA[<%}%>]]>
这篇关于从数据库或常规列表中的自定义控件(DropDownList)中填充数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文