递归在Dropdownlist中显示树状结构
2008-06-10 18:24
344 查看
做项目的时候这种效果很多客户觉得挺好的,挺直观,但是实现呢有点技巧哈,有很多朋友问过我这个问题,今天我就把它贴出来哈:
效果图片:
下面是代码啦:
/// <summary>
/// 返回分类列表
/// </summary>
/// <param name="ParSql">查询条件</param>
/// <param name="LFlag">1为俄文,0为中文</param>
/// <returns></returns>
public DataTable GetType(string QueryStr, string LFlag)
{
DataTable table = COracle.GetTable("tbl_asset_type", "AMGUSER");
DataColumnCollection cols = table.Columns;
string SqlStr = "";
if (QueryStr != "" && QueryStr != null)
{
SqlStr = "select * from tbl_asset_type where " + QueryStr + " order by LBLJ,LBXH";
}
else
{
SqlStr = "select * from tbl_asset_type order by LBLJ, LBXH";
}
cols.Add("PDMMC", typeof(System.String));
Conn.Open();
OracleDataAdapter MyAdpter = new OracleDataAdapter(SqlStr, Conn);
MyAdpter.SelectCommand.ExecuteNonQuery();
MyAdpter.Fill(table);
OracleCommand Mycommand = new OracleCommand();
OracleDataReader Myreader;
for (int i = 0; i < table.Rows.Count; i++)
{
Mycommand.Connection = Conn;
Mycommand.CommandType = CommandType.Text;
Mycommand.CommandText = "select * from tbl_asset_type where bid in (" + table.Rows[i]["LBLJ"] + ") order by LBLJ , LBXH";
Myreader = Mycommand.ExecuteReader();
if (Myreader.HasRows)
{
while (Myreader.Read())
{
table.Rows[i]["PDMMC"] = table.Rows[i]["PDMMC"].ToString() + ">>";
if (LFlag == "1")
{
table.Rows[i]["PDMMC"] = table.Rows[i]["PDMMC"].ToString() + Myreader["DMMC_RU"].ToString();
}
else
{
table.Rows[i]["PDMMC"] = table.Rows[i]["PDMMC"].ToString() + Myreader["DMMC"].ToString();
}
}
}
Myreader.Close();
}
Conn.Close();
return table;
}
转自:http://hi.baidu.com/huqing7002/blog/item/fdd5b20a6124ab1d94ca6b2a.html
效果图片:
下面是代码啦:
/// <summary>
/// 返回分类列表
/// </summary>
/// <param name="ParSql">查询条件</param>
/// <param name="LFlag">1为俄文,0为中文</param>
/// <returns></returns>
public DataTable GetType(string QueryStr, string LFlag)
{
DataTable table = COracle.GetTable("tbl_asset_type", "AMGUSER");
DataColumnCollection cols = table.Columns;
string SqlStr = "";
if (QueryStr != "" && QueryStr != null)
{
SqlStr = "select * from tbl_asset_type where " + QueryStr + " order by LBLJ,LBXH";
}
else
{
SqlStr = "select * from tbl_asset_type order by LBLJ, LBXH";
}
cols.Add("PDMMC", typeof(System.String));
Conn.Open();
OracleDataAdapter MyAdpter = new OracleDataAdapter(SqlStr, Conn);
MyAdpter.SelectCommand.ExecuteNonQuery();
MyAdpter.Fill(table);
OracleCommand Mycommand = new OracleCommand();
OracleDataReader Myreader;
for (int i = 0; i < table.Rows.Count; i++)
{
Mycommand.Connection = Conn;
Mycommand.CommandType = CommandType.Text;
Mycommand.CommandText = "select * from tbl_asset_type where bid in (" + table.Rows[i]["LBLJ"] + ") order by LBLJ , LBXH";
Myreader = Mycommand.ExecuteReader();
if (Myreader.HasRows)
{
while (Myreader.Read())
{
table.Rows[i]["PDMMC"] = table.Rows[i]["PDMMC"].ToString() + ">>";
if (LFlag == "1")
{
table.Rows[i]["PDMMC"] = table.Rows[i]["PDMMC"].ToString() + Myreader["DMMC_RU"].ToString();
}
else
{
table.Rows[i]["PDMMC"] = table.Rows[i]["PDMMC"].ToString() + Myreader["DMMC"].ToString();
}
}
}
Myreader.Close();
}
Conn.Close();
return table;
}
转自:http://hi.baidu.com/huqing7002/blog/item/fdd5b20a6124ab1d94ca6b2a.html
相关文章推荐
- 用递归在Dropdownlist中显示树状结构(连数据库)
- 用递归在Dropdownlist中显示树状结构
- 用递归在Dropdownlist中显示树状结构
- 用递归在Dropdownlist中显示树状结构
- 用递归在Dropdownlist中显示树状结构(连数据库)
- 在jsp页面中实现递归显示树状结构(树状bbs)
- CTE递归应用,树状结构,查询所有子部门、子部门数量、按层级显示部门名称
- DropDownList 无限级分类 树状显示 (递归)
- C#递归在dropdownlist显示树状
- 通过递归方法 将DataTable中的树状数据信息 按树状格式显示在DropDownList中
- 树状结构显示之递归练习并说明写递归代码的技巧
- 用树状结构显示BBS的帖子及其回帖,使用递归方法.
- C#递归在dropdownlist显示树状(转)
- 通过递归方法 将DataTable中的树状数据信息 按树状格式显示在DropDownList中
- ASP 递归显示无穷树状结构, 下拉框中显示树状效果
- 在下拉列表框中显示树状结构
- 关于IE能显示树状结构,而firefox却不能
- 显示树状结构,组织结构图
- [转]在视图中使用递归生成树状结构
- 递归打印目录的树状结构