仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1067|回复: 12
打印 上一主题 下一主题

[学习教程] ASP.NET网页设计带线的无穷级下拉树列表仓酷云

[复制链接]
乐观 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-18 11:15:23 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
net网页编程欺骗了我们那么多年,如今的多核时代,我认为它气数已尽!很多多少年没写文章了
这里就分享点本人原创的一点破代码,效果如图下:

自己的供应的代码以下:
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Text;
usingSystem.Web.UI.WebControls;

namespaceInterface.Common
{
publicinterfaceIDropDownTree:IDisposable
{
///<summary>
///前往Dictionary里分离对应ID,文本,假如没有子节点前往null
///</summary>
///<paramname="parentID">父节点ID</param>
///<returns></returns>
Dictionary<string,string>GetChildCategory(stringparentID);
///<summary>
///代码里写returnnewInterface.Common.DropDownTree(this);
///</summary>
DropDownTreeDropDownTree
{
get;
}
}
publicsealedclassDropDownTree
{
IDropDownTree_DropDownTree;
publicDropDownTree(IDropDownTreedropDownTree)
{
_DropDownTree=dropDownTree;
}
///<summary>
///用于树的前缀
///</summary>
///<paramname="IsLast">是不是是同级节点中的最初一个</param>
///<paramname="HasChild">本节点是不是具有子节点</param>
///<paramname="ParentString">父节点前缀标记</param>
///<returns>本节点的前缀</returns>
privatestringGetPreFix(boolisLast,boolhasChild,stringparentString)
{
stringresult=string.Empty;
if(!string.IsNullOrEmpty(parentString))
{
parentString=parentString.Remove(parentString.Length-1).Replace("├","│").Replace("└"," ");
result+=parentString;
}
if(isLast)
{
result+="└";
}
else
{
result+="├";
}
if(hasChild)
{
result+="┬";
}
else
{
result+="─";
}
returnresult;
}
绑定下拉菜单
}
}

挪用办法很复杂:
1.承继自IDropDownTree接口
2.完成3个接口办法

完成接口代码示例[Dispose办法本人完成],最次要的是本人完成取得子级的办法
#regionIDropDownTree成员

publicDictionary<string,string>GetChildCategory(stringparentID)
{
stringwhere="ParentID="+parentID+"";
if(string.IsNullOrEmpty(parentID))
{
where="ParentIDisnullorParentID="+Guid.Empty+"";
}
List<GoodsCategoryBean>_GoodsCategoryList=SelectList(0,where,string.Empty,false);
if(_GoodsCategoryList!=null&&_GoodsCategoryList.Count>0)
{
Dictionary<string,string>categoryList=newDictionary<string,string>();
for(inti=0;i<_GoodsCategoryList.Count;i++)
{
categoryList.Add(_GoodsCategoryList.ID.ToString(),_GoodsCategoryList.GategoryName);
}
returncategoryList;
}
returnnull;
}

publicInterface.Common.DropDownTreeDropDownTree
{
get{returnnewInterface.Common.DropDownTree(this);}
}

#endregion
页面挪用代码:类名.DropDownTree.BindToDropDownList(下拉控件ID);

但愿对年夜伙有点匡助....
一个很大的类库。应用程序之所以难以跨平台,在于直接调用了特定平台的接口,而一个巨大的类库,就能极大地减少应用程序对平台的依赖。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-20 01:16

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表