Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 30th, 2006, 02:07 PM
Authorized User
 
Join Date: Mar 2006
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
 
Old April 30th, 2006, 06:55 PM
Friend of Wrox
 
Join Date: Apr 2004
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

 
Old May 2nd, 2006, 02:21 AM
Authorized User
 
Join Date: Mar 2006
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:)
 
Old May 2nd, 2006, 02:38 AM
Authorized User
 
Join Date: Mar 2006
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





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.