发现ASP.NET2.0的树型控件少了个SelectExpands属性。郁闷!

在ASP.NET 1.x中安装的MS TREE控件中有SelectExpands属性,而在ASP.NET2.0中我找不到,要达到同样的效果,必须在节点中设置t1.SelectAction = TreeNodeSelectAction.Expand; 

protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
           
            OleDbDataAdapter odda = new OleDbDataAdapter("select note_id,parent_id,function_name,url,expanded from sys_tree where display=1 order by order_id asc", conn);
            odda.Fill(ds);
            creattree(ds.Tables[0].Rows[0][2].ToString(), ds.Tables[0].Rows[0][3].ToString(), null, 1, Convert.ToInt32(ds.Tables[0].Rows[0]["expanded"]));
        }
        catch (OleDbException ex)
        {
            Response.Write(ex.Message);

        }
    }
    void creattree(string text, string url, TreeNode tnd, int pid, int expanded)
    {
        TreeNode t1 = new TreeNode();
        //t1.ID = pid.ToString();
        t1.Value = pid.ToString();
        t1.Text = text;
       t1.NavigateUrl = url;
        t1.Target = "Main";
        t1.SelectAction = TreeNodeSelectAction.Expand;//和ASP.NET1.1中TREEVIEW的SelectExpands属性等效       
        if (expanded == 1) t1.Expanded = true;
        else t1.Expanded = false;
       
        if (pid == 1) Treeview1.Nodes.Add(t1);
        else tnd.ChildNodes.Add(t1);
        //else tnd.Nodes.Add(t1);

        string str1 = "parent_id =" + pid;
        DataRow[] dryl = ds.Tables[0].Select(str1);

        for (int i = 0; i <= dryl.GetUpperBound(0); i++)
        {

            creattree(dryl[i][2].ToString(), dryl[i][3].ToString(), t1, Convert.ToInt32(dryl[i][0]), Convert.ToInt32(dryl[i][4]));
        }

你可能感兴趣的:(asp.net)