/// <summary>
/// 递归添加数据
/// </summary>
/// <param name="table"></param>
/// <param name="ParentID"></param>
/// <param name="deep"></param>
void add(DataTable table, int ParentID, int deep)
{
DataRow[] rowlist = table.Select("ParentID=" + ParentID);
foreach (var item in rowlist)
{
string strPading = "";
for (int i = 0; i < deep; i++)
{
strPading += "--";
}
DataRow row = dt.NewRow();
row["BranchName"] = strPading + item["BranchName"];
row["ID"] = item["ID"];
dt.Rows.Add(row);
add(table, Convert.ToInt32(item["ID"]), deep + 1);
}
}
通过递归实现下拉框的层次结构
最新推荐文章于 2020-09-04 18:20:23 发布