private void BindDDL(int zfid)
    { string sql = “SELECT id, cntitle ,fid  FROM T_lm  where fid=” + zfid + ” and ty<>4 and isshow=1 order by [sort] asc”;
        DataSet ds = Db.GreatDs(sql);
        DataView treedv = new DataView(ds.Tables[0]);
        foreach (DataRowView Row in treedv)
        {
            ddlm.Items.Add(new ListItem(“├” + Row[“cntitle”].ToString(), Row[“id”].ToString()));
            if (sc.tonum(Row[“id”].ToString()) > 0)
            {
                string sql1 = “select id, cntitle ,fid from T_lm where fid=” + Row[“id”].ToString() + ”  and ty<>4 and isshow=1″;
                DataSet ds1 = Db.GreatDs(sql1);
                DataView treedv1 = new DataView(ds1.Tables[0]);
                foreach (DataRowView Row1 in treedv1)
                {                   
                    ddlm.Items.Add(new ListItem(“–“+”├” + Row1[“cntitle”].ToString(), Row1[“id”].ToString()));
                  
                }
            }
        }
        ddlm.Items.Insert(0, new ListItem(“–请选择栏目–“, “0”));

}

<asp:DropDownList ID=”ddlm” runat=”server”>
        </asp:DropDownList>

版权声明:本文为panlin原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/panlin/archive/2012/09/05/2671350.html