加载出一个有层次的下拉框
2016-05-27 10:35
197 查看
public void getOneClassTree(int classid, System.Web.UI.WebControls.DropDownList cid, int _depth = 0)
{
string texts = "";
string values = "";
int depth = _depth;
BLL.manager_Department BLL_商品 = new BLL.manager_Department();
Model.manager_Department cate = new Model.manager_Department();
//获取商品类别对象
cate = BLL_商品.GetModel(classid);
DataTable dt_Have = SqlHelpers.GetDataTableBySQL("select * from manager_Department where parent_id=" + classid + " order by parent_id");
for (int i = 0; i < depth; i++)
{
texts += " ";
}
values = cate.id.ToString();
if (dt_Have.Rows.Count == 0)
{
texts += " - " + cate.dep_name;
cid.Items.Add(new ListItem(texts, values));
}
else
{
texts += " + " + cate.dep_name;
cid.Items.Add(new ListItem(texts, values));
DataTable classidArry1 = SqlHelpers.GetDataTableBySQL("select * from manager_Department where parent_id=" + classid + " order by parent_id");
foreach (DataRow dr in classidArry1.Rows)
{
getOneClassTree(Convert.ToInt32(dr["id"]), cid, depth + 1);
}
}
}
{
string texts = "";
string values = "";
int depth = _depth;
BLL.manager_Department BLL_商品 = new BLL.manager_Department();
Model.manager_Department cate = new Model.manager_Department();
//获取商品类别对象
cate = BLL_商品.GetModel(classid);
DataTable dt_Have = SqlHelpers.GetDataTableBySQL("select * from manager_Department where parent_id=" + classid + " order by parent_id");
for (int i = 0; i < depth; i++)
{
texts += " ";
}
values = cate.id.ToString();
if (dt_Have.Rows.Count == 0)
{
texts += " - " + cate.dep_name;
cid.Items.Add(new ListItem(texts, values));
}
else
{
texts += " + " + cate.dep_name;
cid.Items.Add(new ListItem(texts, values));
DataTable classidArry1 = SqlHelpers.GetDataTableBySQL("select * from manager_Department where parent_id=" + classid + " order by parent_id");
foreach (DataRow dr in classidArry1.Rows)
{
getOneClassTree(Convert.ToInt32(dr["id"]), cid, depth + 1);
}
}
}
相关文章推荐
- 在spark中操作mysql数据 ---- spark学习之七
- leetcode Maximum Product of Word Lengths
- MYSQL中关于编码问题
- Python入门重点
- CentOS 6.5 Transmission 安装
- Oracle高级查询之OVER (PARTITION BY ..)
- iOS原生代码通过webView与js脚本交互
- iOS—修改AFNetworking源文件可接收text/plain的方法
- Linux C编程章节二:常用类型和预处理器
- 正则表达式汇总
- Android PullToRefresh下拉到底部自动加载下一页
- 面试题21:包含min函数的栈,面试题22:判断某一序列是否是出栈序列
- UNIX网络编程笔记(3)—基本TCP套接字编程
- shell常用命令之六 alias
- activiti eclipse 插件不自动生成png
- App For Mac
- jq 智能搜索
- 安卓初识控件_DatePicker
- iOS—修改AFNetworking源文件可接收text/plain的方法
- Linux下实现类似SecureCRT的复制Session功能