![]() //绑定所有目录
//绑定所有目录
![]() public static void Bind_list(DropDownList DropDownList1)
    public static void Bind_list(DropDownList DropDownList1)
![]()
![]() 
    ![]() {
{
![]() DropDownList1.Items.Clear();
        DropDownList1.Items.Clear();
![]() string sql = "SELECT list_id,list_name,list_parent FROM list";
        string sql = "SELECT list_id,list_name,list_parent FROM list";
![]() DataTable dt = DataBase.getDataTable(sql);  //根据SQL语句获取DataTable值
        DataTable dt = DataBase.getDataTable(sql);  //根据SQL语句获取DataTable值
![]() Bind_list(DropDownList1,dt, "0", 0);
        Bind_list(DropDownList1,dt, "0", 0);
![]() }
    }
![]()
![]() private static void Bind_list(DropDownList DropDownList1, DataTable dt, string parent, int grade)
    private static void Bind_list(DropDownList DropDownList1, DataTable dt, string parent, int grade)
![]()
![]() 
    ![]() {
{
![]() DataRow[] dr = dt.Select("list_parent=" + parent, "list_id asc");
        DataRow[] dr = dt.Select("list_parent=" + parent, "list_id asc");
![]() if (dr.Length > 0)
        if (dr.Length > 0)
![]()
![]() 
        ![]() {
{
![]() int grade1 = grade + 1;
            int grade1 = grade + 1;
![]() foreach (DataRow row in dr)
            foreach (DataRow row in dr)
![]()
![]() 
            ![]() {
{
![]() ListItem li = new ListItem();
                ListItem li = new ListItem();
![]() li.Text = "";
                li.Text = "";
![]() for (int i = 0; i < grade; i++)
                for (int i = 0; i < grade; i++)
![]()
![]() 
                ![]() {
{
![]() li.Text += " ";
                    li.Text += " ";
![]() }
                }
![]() li.Text += "├" + row[1].ToString();
                li.Text += "├" + row[1].ToString();
![]() li.Value = row[0].ToString();
                li.Value = row[0].ToString();
![]() DropDownList1.Items.Add(li);
                DropDownList1.Items.Add(li);
![]() Bind_list(DropDownList1,dt, row[0].ToString(), grade1);
                Bind_list(DropDownList1,dt, row[0].ToString(), grade1);
![]() }
            }
![]() }
        }
![]() }
    }