重写DROPDOWNLIST
public class TypeDDL : DropDownList
{
private void ShowOption()
{
PhotoType myobj = new PhotoType();
DataTable dt = myobj.TypeInfo(false);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
if(Convert.ToString(dt.Rows[i]["ParentId"])=="0")
this.Items.Add(new ListItem("╋" + Convert.ToString(dt.Rows[i]["TypeName"]), Convert.ToString(dt.Rows[i]["TypeId"])));
else
this.Items.Add(new ListItem("\0├" + Convert.ToString(dt.Rows[i]["TypeName"]), Convert.ToString(dt.Rows[i]["TypeId"])));
}
}
myobj=null;
}
protected override void CreateChildControls()
{
if (!Page.IsPostBack)
{
this.ShowOption();
}
this.DataBind();
}
}
这里只是二级的,如果是更高级,就在多几个判断!