locked
treeview RRS feed

  • Question

  • User2127906842 posted

    Hi,

    How can I make the treeview control display data from a database instead of displaying data from a sitemap?

    Thanks in advance.

    Tuesday, June 28, 2005 1:41 PM

All replies

  • User-1379775122 posted

                using (SqlConnection connCurr = new SqlConnection(@"Data Source=DOHWKH203285\SQLExpress;Initial Catalog=SQLCLRTest;Integrated Security=True"))
                {               
                    connCurr.Open();
                    string strExecute = "Select * From Menu M " +
                        "LEFT OUTER JOIN MENU MC ON M.MenuId = MC.MenuParentId " +
                        "LEFT OUTER JOIN MENU MCC ON MC.MenuId = MCC.MenuParentId " +
                        "Where M.MenuParentId IS NULL";

                    SqlDataAdapter sdaMenu = new SqlDataAdapter(strExecute, connCurr);
                    DataSet dsMenu = new DataSet();
                    sdaMenu.Fill(dsMenu);

                    //XmlDocument docMenu = new XmlDocument();
                    //docMenu.LoadXml(dsMenu.GetXml());

                    XmlDataSource1.Data = dsMenu.GetXml();

                    tvTest.DataSource = XmlDataSource1;
                    tvTest.DataBind();
                   
                } // end using


    Tuesday, June 28, 2005 5:13 PM
  • User2127906842 posted
    Hi TylerFree,

    I was wondering where I should put this code into, and can't I use an ObjectDataSource to do this? why?

    Thank you.
    Wednesday, June 29, 2005 2:19 PM