Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 30th, 2006, 02:07 PM
Authorized User
 
Join Date: Mar 2006
Location: Sofia, , Bulgaria.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to kalchev
Default Strange Problem with NavigateUrl in TreeView

Hello,
I have strange problem and hope somebody can give an advice. So I populate my treeview OnTreeNodePopulate="Node_Populate" and i put on the every node over 1-st level a NavigateURL .. But when I run it I can only click on the Root and first Child node and on the other I have no possibility to click. So what can I do to repair this? Any advice is welcome:)
Here is the codebehind:

Code:
    Private Sub Node_Populate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs)
 
        If e.Node.ChildNodes.Count = 0 Then
 
            Select Case e.Node.Depth
 
                Case 0
 
                    FillFirstLvl(e.Node)
 
                    Exit Sub
 
                Case 1
 
                    FillSecondLevel(e.Node)

                    Exit Sub

                Case 2

                    LastFill(e.Node)
 
                    Exit Sub
            End Select
 
        End If
 
    End Sub
 
 
 
    Private Sub FillFirstLvl(ByVal node As TreeNode)


        Dim connString As String = ConfigurationManager.ConnectionStrings("autodib").ConnectionString
 
        Dim connection As New OleDb.OleDbConnection(connString)
 
        Dim command As New OleDb.OleDbCommand("SELECT * from MarkaNaKola", connection)
 
        Dim adapter As New OleDb.OleDbDataAdapter(command)
 
        Dim Views As New DataSet()
 
        adapter.Fill(Views)
 
        If Views.Tables.Count > 0 Then
 
            Dim row As DataRow
            For Each row In Views.Tables(0).Rows
 
                Dim NewNode As TreeNode = New TreeNode(row("markakola").ToString())
                NewNode.PopulateOnDemand = True
 
                NewNode.SelectAction = TreeNodeSelectAction.Expand
 
                node.ChildNodes.Add(NewNode)
 
            Next
 
        End If
 
    End Sub
 
 
 
    Public Sub FillSecondLevel(ByVal node As TreeNode)

        Dim MarkaKola As String = node.Value
        Dim connString As String = ConfigurationManager.ConnectionStrings("autodib").ConnectionString
 
        Dim a As String = "SELECT MarkaNaKola.markakola, Kategoria.CatName FROM MarkaNaKola" & " INNER JOIN Kategoria ON MarkaNaKola.markakola = Kategoria.markakola" & " WHERE MarkaNaKola.markakola = '" & MarkaKola & " '" & " ORDER BY Kategoria.CatName"

        Dim connection As New OleDb.OleDbConnection(connString)
        Dim command As New OleDb.OleDbCommand(a, connection)
        Dim adapter As New OleDb.OleDbDataAdapter(command)
 
        Dim titlesForViews As New DataSet()
 
        adapter.Fill(titlesForViews)
 
        If titlesForViews.Tables.Count > 0 Then
 
            Dim row As DataRow
            For Each row In titlesForViews.Tables(0).Rows
                Dim NewNode As TreeNode
                'NewNode = New TreeNode(row("CatName").ToString(), row("CategorID").ToString())
                NewNode = New TreeNode(row("CatName").ToString())
                NewNode.PopulateOnDemand = True
 
                NewNode.SelectAction = TreeNodeSelectAction.None
                node.NavigateUrl = String.Format("~/VtoroNivo.aspx?markakola=""{0}""", MarkaKola)
                node.ChildNodes.Add(NewNode)
 
            Next
 
        End If
 
    End Sub

    Private Sub LastFill(ByVal node As TreeNode)
        Dim MarkaNaKola As String = node.Parent.Value
        Dim Kategoria As String = node.Value
        Dim connString As String = ConfigurationManager.ConnectionStrings("autodib").ConnectionString
        Dim LastFillCmd As String = "SELECT MarkaNaKola.markakola, Kategoria.CatName, Produkti.ImeProd FROM ((MarkaNaKola INNER JOIN Kategoria ON MarkaNaKola.markakola = Kategoria.markakola) INNER JOIN Produkti ON Kategoria.CategorID = Produkti.CategorID) WHERE (MarkaNaKola.markakola ='" & MarkaNaKola & "'AND (Kategoria.CatName = '" & Kategoria & "'))" & "ORDER BY Kategoria.CatName, Produkti.ImeProd"

        Dim connection As New OleDb.OleDbConnection(connString)
        Dim command As New OleDb.OleDbCommand(LastFillCmd, connection)
        Dim adapter As New OleDb.OleDbDataAdapter(command)
        Dim LastFill As New DataSet()
 
        adapter.Fill(LastFill)
 
        If LastFill.Tables.Count > 0 Then
 
            Dim row As DataRow
            For Each row In LastFill.Tables(0).Rows
                Dim NewNode As TreeNode
                NewNode = New TreeNode(row("ImeProd").ToString())
                NewNode.PopulateOnDemand = True
 
                NewNode.SelectAction = TreeNodeSelectAction.None

                node.NavigateUrl = String.Format("~/VtoroNivo.aspx?markakola=""{0}""", MarkaNaKola)
                node.ChildNodes.Add(NewNode)
 
            Next
 
        End If
 
    End Sub



And here is the Html part:

Code:
        <asp:TreeView ID="Treeviewz" Runat="Server" ExpandImageUrl="TreeLineImages/minus.gif"

              CollapseImageUrl="TreeLineImages/plus.gif"

              OnTreeNodePopulate="Node_Populate">

            <Nodes>

                <asp:TreeNode SelectAction=SelectExpand Text="auto dib" PopulateOnDemand=true/>

            </Nodes>

        </asp:TreeView>


Thank You,
G. Kalchev
Reply With Quote
  #2 (permalink)  
Old April 30th, 2006, 06:55 PM
Friend of Wrox
 
Join Date: Apr 2004
Location: San Francisco, CA, USA.
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi G.

Where are you binding your TreeView? It's not in the declaration, so it must be in code. Can we see that code?

Aaron

Reply With Quote
  #3 (permalink)  
Old May 2nd, 2006, 02:21 AM
Authorized User
 
Join Date: Mar 2006
Location: Sofia, , Bulgaria.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to kalchev
Default

THank you Aaron,
Actually this is the whole code, and I bind it here: OnTreeNodePopulate="Node_Populate". The code is up there:)
Reply With Quote
  #4 (permalink)  
Old May 2nd, 2006, 02:38 AM
Authorized User
 
Join Date: Mar 2006
Location: Sofia, , Bulgaria.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to kalchev
Default

I found the problem.. Really stupid my fault:

change
 NewNode.SelectAction = TreeNodeSelectAction.None
to
 NewNode.SelectAction = TreeNodeSelectAction.Select
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
strange IE problem sully7 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 September 19th, 2008 08:44 AM
NavigateUrl and Target spacy ASP.NET 1.x and 2.0 Application Design 9 November 5th, 2007 12:23 PM
Strange problem... F3553 C++ Programming 1 October 25th, 2007 03:56 PM
strange problem with EditItemTemplate hertendreef ASP.NET 2.0 Professional 0 August 17th, 2006 08:44 AM
very strange problem! please help! raybristol ASP.NET 1.0 and 1.1 Basics 8 December 15th, 2005 06:46 AM



All times are GMT -4. The time now is 06:28 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.