public string listStr = "";
protected void Page_Load(object sender, EventArgs e)
{
LoadList();
}
/// <summary>
/// 加载整个分类表
/// </summary>
private void LoadList()
{
listStr = "";
int MTcount = 0;//执行遍历的次数
//开始迭代加载
MakeTr("0", MTcount);
}
/// <summary>
/// 装配每一行
/// </summary>
/// <param name="id">上级ID</param>
/// <param name="count">迭代次数</param>
private void MakeTr(string id, int count)
{
DataView dv = Web.App_Code.Live.Live_Class_Manage.GetClassListByParentID(id);
foreach (DataRowView drv in dv)
{
//形成表格
//listStr += "<tr><td>" + MakeFelgefu(count) + drv["context"].ToString() + "</td><td>自身编号" + drv["id"].ToString() + ",上级编号" + id + "</td></tr>";
listStr += "<tr><td class=\"td_bg_center\" width=\"20%\" height=\"23\"> " + drv["ClassID"].ToString() + "</td><td class=\"td_bg\" width=\"20%\">" + MakeFelgefu(count) + drv["ClassName"].ToString() + "</td><td class=\"td_bg_center\" width=\"20%\">" + GetParentClassNameByClassID(drv["ClassParentID"].ToString()) + "</td><td class=\"td_bg_center\" width=\"20%\">" + drv["ClassPath"].ToString() + "</td><td class=\"td_bg_center\" width=\"20%\"><a href=\"Live_Class_Add.aspx?ClassID=" + drv["ClassID"].ToString() + "&ParentID=" + drv["ClassParentID"].ToString() + "&Action=Delete\">删除</a> <a href=\"Live_Class_Add.aspx?ClassID=" + drv["ClassID"].ToString() + "&ParentID=" + drv["ClassParentID"].ToString() + "&Action=Update\">修改</a> <a href=\"Live_Class_Add.aspx?ClassID=" + drv["ClassID"].ToString() + "&ParentID=" + drv["ClassParentID"].ToString() + "&Action=Add\">添加子栏目</a></td></tr>";
//形成下拉列表
//再次遍历
MakeTr(drv["ClassID"].ToString(), count + 1);
}
dv.Dispose();
}
/// <summary>
/// Make分隔符
/// </summary>
/// <param name="count"></param>
/// <returns></returns>
private string MakeFelgefu(int count)
{
string Returnwords = string.Empty;
if (count == 0)
{
Returnwords = "";
}
else
{
Returnwords = ("├").PadLeft(count, ' ');
}
return Returnwords;
}
----------------------------------------------------
/// <summary>
/// 加载整个分类表
/// </summary>
private void LoadList()
{
ListItem lit = new ListItem("所有栏目", "0");
ddlClass.Items.Insert(0, lit);
int MTcount = 0;//执行遍历的次数
MakeTr("0", MTcount);//开始迭代加载
}
/// <summary>
/// 装配每一行
/// </summary>
/// <param name="id">上级ID</param>
/// <param name="count">迭代次数</param>
private void MakeTr(string id, int count)
{
DataView dv = Web.App_Code.Live.Live_Class_Manage.GetClassListByParentID(id);
foreach (DataRowView drv in dv)
{
//形成下拉列表
ListItem li = new ListItem(MakeFelgefu(count) + drv["ClassName"].ToString(), drv["ClassID"].ToString());
ddlClass.Items.Add(li);
//再次遍历
MakeTr(drv["ClassID"].ToString(), count + 1);
}
dv.Dispose();
}
/// <summary>
/// Make分隔符
/// </summary>
/// <param name="count"></param>
/// <returns></returns>
private string MakeFelgefu(int count)
{
string Returnwords = string.Empty;
if (count == 0)
{
Returnwords = "";
}
else
{
Returnwords = ("├").PadLeft(count, ' ');
}
return Returnwords;
}