CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2009
    Posts
    22

    dynamic treeview problem

    I have a treeview control in ASP.NET and C#.

    Root node This is fixed
    ---Parent Node 1 Parent node and child are populated from the database directly.
    ----Child node1
    ----Child node2
    ---Parent node 2

    Now When a value is added to a database it get added in the treeview.
    I cannot get a way to select the parent and child node and make it perform a function like go to another page or something.....

    Please help me.... urgent

  2. #2
    Join Date
    Jan 2009
    Posts
    22

    Re: dynamic treeview problem

    I have the code to retrieve values from the database and display on the treenode dynamically.
    Just the selection is a problem.

    If there is a tutorial of any other information please let me kow

  3. #3
    Join Date
    Jan 2009
    Posts
    22

    Re: dynamic treeview problem

    Is there no 1 who knows the answer to this?/?
    Even how to go about information will do.

  4. #4
    Join Date
    Oct 2005
    Posts
    175

    Thumbs up Re: dynamic treeview problem

    Dear Jagmit,

    I dont have idea about c#, but I tell u what I have done in vb.net.
    I have created a table where I have kept all the menus (parent nodes and child nodes).
    table structure is like this:
    menuId- MenuName- menuLevel-FormId

    menuLevel keeps an integer value of parent(1 level) or and chile(2 level or 3 level)

    I have another table in which I have kept all my forms (along with unique form id).
    when the form is loaded, the tree is filled and menu id is assigned to each tree nodes as below:

    nodeAuthor.value = Trim(reader("MenuId").ToString)

    when ever user clicks any menu the value is assigned to a global variable(session variable) as below

    Sub MenuSelected(ByVal sender As Object, ByVal e As EventArgs)
    Session("VpMnuItem") = VisaProDetMenu.SelectedNode.Value
    end sub

    I have writen one query, which picks the form id from menus table and formName from 'forms' table as below:

    SELECT a.MenuId, b.FormId, b.FormName FROM T_LT_Menus a LEFT OUTER JOIN "
    T_LT_FormsReports b ON a.FormFid = b.FormId
    Where a.MenuId='" & Session("VpMnuItem") & "' "

    I have used following syntax to open a new page

    MyConn.Open()
    Dim Cmd As New SqlCommand(strSQL, MyConn)
    Dim reader As SqlDataReader = Cmd.ExecuteReader()
    If reader.HasRows Then
    reader.Read()
    If Trim(reader("FormId").ToString) > 0 Then
    Session("VpFormId") = Trim(reader("FormId").ToString)
    pageToDisplay = Trim(reader("FormName").ToString)
    Else
    pageToDisplay = "NONE"
    End If
    Else
    pageToDisplay = "NONE"
    End If
    reader.Close()
    MyConn.Close()
    Catch Ex As Exception
    MsgBox(Ex.Message.ToString)
    End Try
    If pageToDisplay <> "NONE" Then
    Response.Redirect(pageToDisplay)
    End If


    if it helps u, please let me know.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured