做项目的时候这种效果很多客户觉得挺好的,挺直观,但是实现呢有点技巧哈,有很多朋友问过我这个问题,今天我就把它贴出来哈:
效果图片:
![](https://i-blog.csdnimg.cn/blog_migrate/2e8062a35b1a8f555cb6ffcc37189b83.jpeg)
下面是代码啦:
/// <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;
}
/// 返回分类列表
/// </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;
}