add node in treeview nad display

Discussion in 'C#' started by virusisfound, Sep 2, 2010.

  1. virusisfound

    virusisfound New Member

    Joined:
    Sep 2, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I am working on tree View in taht i want to do two thinks i.e
    1. add new node at run time
    2. what data is stored in a database is shown in the tree view as parent node and
    its child

    for second i have do some coding it shows data as parent and child node but problem is it shows only one row record can any one help me correct the coding please

    Code:
       SqlConnection con = new SqlConnection("USER=userid;PASSWORD=password;SERVER=servername;DATABASE=database");
                string SQLQuery;
                SQLQuery = "select tablename,displayname from Tablename";
                DataSet ds=new DataSet();
                SqlDataAdapter da=new SqlDataAdapter(SQLQuery,con);
                da.Fill(ds);
                foreach ( DataRow Row in ds.Tables[0].Rows)
                {
                    TreeNode Tnode = new TreeNode("ParentNode");
                    treeView1.Nodes.Add(Tnode);
    }
    Thanks.....
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice