ASP.Net DropDownList绑定树状结构
2011-03-28 11:22
429 查看
获取父节点开始调用listSource是List<>数据集合(有父子关系)
递归绑定
foreach(ModelInfoIteminlistSource)
{
if(Item.ParentID==0)
{
ListItemli=newListItem();
li.Text=Item.Item;
li.Value=Item.ID.ToString();
YouDropDownList.Items.Add(li);
BindDDLData(YouDropDownList,listSource,Item,"├à─¤─¤");
}
}
递归绑定
privatevoidBindDDLData(DropDownListDdl,List<ModelInfo>List,ModelInfoCurrentInfo,stringseparator)
{
varquer=(fromcinList
wherec.ParentID==CurrentInfo.ID
selectc);
foreach(variteminquer)
{
ListItemli=newListItem();
li.Text=separator+item.Item;
li.Value=item.ID.ToString();
Ddl.Items.Add(li);
stringseparator_=separator+"─¤─¤─¤";
BindDDLData(Ddl,List,item,separator_);
}
}
相关文章推荐
- ASP.Net DropDownList绑定树状结构
- 在ASP.NET MVC中为DropDownList 绑定数据库的值
- Asp.Net--DropDownList与DataTable数据绑定的方法(C#)[学习笔记]
- ASP.NET中DropDownList控件的简单使用--DDL绑定数据库表中值,选择DDL中值直接检索数据
- ASP.NET中DropDownList下拉框列表控件绑定数据的4种方法
- asp.net实现XML文件读取数据绑定到DropDownList的方法
- asp.net的DropDownList通用绑定代码
- ASP.NET中dropdownlist 动态绑定数据的二种方法
- asp.net 获取安装的所有字体,并绑定dropdownlist
- ASP.net:三层Web体系结构里的两种数据绑定模式
- ASP.NET中 DropDownList+Repeater的使用前台绑定
- 技术笔记1_ASP.net:如何让DropDownList之类的单值绑定控件绑定多个字段值
- Asp.net Webform 数据源绑定控件的扩展(懒人的办法):DropDownList
- ASP.NET中DropDownList控件的简单使用--DDL绑定数据库表中值,选择DDL中值直接检索数据
- ASP.NET DropDownList 的层级绑定
- [ASP.NET]利用DataTable对DropDownList进行数据绑定
- ASP.NET - List<> 绑定 DropDownList
- ASP.NET - JQuery的.getJSON给Dropdownlist绑定Item
- 理解asp.net中DropDownList编辑数据源,绑定数据库数据。
- Asp.net实现继承于DropDownList的树状控件(转)