built treeview from SQLSERVER Database

Discussion in 'ASP .Net' started by Jaidev Paruchuri, Apr 14, 2004.

  1. Hello Everybody,

    I am new to .NET.
    I need to build a treeview which must be populated from SQL Server
    Database.
    I tried to my level best,but couldnt find a solution for it.

    I have a table called mn_doc_master.

    doc_id int
    cat_id int
    short_title char(20)
    doc_type char(1)

    I need to populate the treeview based on this table.
    cat_id is a category.
    short_title is the text to appear on the node.
    doc_type mentions wheather the current document is a folder or
    document.

    i have values like

    1,0,'1st Folder','F'
    2,1,'1-1 Document','D'
    3,1,'1-2 Document','D'
    4,0,'2nd Folder','F'
    5,4,'2-1 Folder','F'
    and so on...

    I need to build a tree based on these values..it should be in
    heirarchial manner like

    1st Folder
    1-1 Document
    1-2 Document
    2nd Folder
    2-1 Folder
    2-1-1 Folder
    and so on..

    I tried the following way.
    ----------------------------------------------------------------------------
    Dim daDocs As New SqlClient.SqlDataAdapter("SELECT
    short_title,doc_id,cat_id FROM mn_doc_master ORDER BY cat_id.doc_id ",
    myConnection)

    daDocs.Fill(objDS, "dtDocs")

    Dim nodeDoc, nodeCat As TreeNode
    Dim rowSupp, rowProd As DataRow

    For Each rowSupp In objDS.Tables("dtDocs").Rows
    nodeDoc = New TreeNode
    nodeDoc.Text = rowSupp("short_title")
    nodeDoc.ID = rowSupp("doc_id")
    Dim cat_id = rowSupp("cat_id")
    Treeview1.Nodes.AddAt(cat_id, nodeDoc)
    Next
    ------------------------------------------------------------------------------

    Thanks in Advance,
     
    Jaidev Paruchuri, Apr 14, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kelly G.
    Replies:
    0
    Views:
    545
    Kelly G.
    Jan 8, 2004
  2. Thierry
    Replies:
    1
    Views:
    587
    Michael
    Jan 15, 2004
  3. Selen

    sqlserver database suspect

    Selen, Jan 29, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    695
    =?Utf-8?B?RWR3YXJk?=
    Jan 29, 2004
  4. Kevin Jackson
    Replies:
    0
    Views:
    1,058
    Kevin Jackson
    May 18, 2006
  5. =?Utf-8?B?SmVmZnJleQ==?=

    Upgrading ASP w/SQLserver 2000 to ASP.NET w/ SQLserver 2005

    =?Utf-8?B?SmVmZnJleQ==?=, Apr 6, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    482
    sloan
    Apr 27, 2007
Loading...

Share This Page