Tree View to be refreshed with out screen refreshing???

Last post 05-09-2008 4:43 AM by AxleWack. 3 replies.

Sort Posts:

  • Tree View to be refreshed with out screen refreshing???

    05-05-2008, 3:26 AM
    • Loading...
    • AxleWack
    • Joined on 10-02-2007, 4:56 AM
    • Posts 248

    Hi,

     

    I have a treeview on a page, when I select a node it displays the selected node's name on a label and highlights the selected node in red - This works... but does a terrible refresh of the page before excecuting this......

     

    Ive used and update panel(AJAX), but when it "refreshes" the treeview, it :

    1. Doesnt Highlight the selected node in red

    2. Duplicates the "FIRST" selected nodes text everytime a node is selected......

     Does anyone know of a way to stop this from happening???

     

    Thank you for any assistance....

  • Re: Tree View to be refreshed with out screen refreshing???

    05-05-2008, 5:01 AM
    • Loading...
    • AxleWack
    • Joined on 10-02-2007, 4:56 AM
    • Posts 248

    Perhaps this will help a bit : This is my code below

     

    Private Sub PopulateRootLevel()

    Dim objConn As String = ConfigurationManager.AppSettings("Fleetcube.ConnectionString")

    Dim myConnection As New System.Data.SqlClient.SqlConnection(objConn)

    Dim objCommand As New SqlCommand("select id,name,(select count(*) FROM org_Branch " _

    & "WHERE parentBranchID=id) childnodecount FROM org_Branch where parentBranchID = 0", _

    myConnection)

     

    Dim da As New SqlDataAdapter(objCommand)Dim dt As New DataTable()

    da.Fill(dt)

     

    PopulateNodes(dt, TreeView1.Nodes)

    End Sub

     

    'Nodes

    Private Sub PopulateNodes(ByVal dt As DataTable, _

    ByVal nodes As TreeNodeCollection)

    For Each dr As DataRow In dt.Rows

    Dim tn As New TreeNode()

    tn.Text = dr("name").ToString()tn.Value = dr("id").ToString()

    nodes.Add(tn)

     

    'If node has child nodes, then enable on-demand populating

    tn.PopulateOnDemand = (CInt(dr("childnodecount")) > 0)

    Next

    End Sub

     

    'Sub levels

    Private Sub PopulateSubLevel(ByVal parentid As Integer, ByVal parentNode As TreeNode)

    Dim objConn As String = ConfigurationManager.AppSettings("Fleetcube.ConnectionString")

    Dim myConnection As New System.Data.SqlClient.SqlConnection(objConn)

    Dim objCommand As New SqlCommand("select id,name,(select count(*) FROM org_Branch " _

    & "WHERE parentBranchID=id) childnodecount FROM org_Branch where parentBranchID=@parentBranchID", _

    myConnection) '//////////////////////

     

     

    Dim da As New SqlDataAdapter(objCommand)Dim dt As New DataTable()

    da.Fill(dt)

    objCommand.Parameters.Add(
    "@parentBranchID", SqlDbType.Int).Value = parentid

    PopulateNodes(dt, parentNode.ChildNodes)

    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

    If Not Page.IsPostBack Then

    PopulateRootLevel()

    End If

    end sub

  • Re: Tree View to be refreshed with out screen refreshing???

    05-06-2008, 11:51 PM
    Answer

    Hi,

    In fact,  the ASP.Net Menu and the Treeview control are not compatible with with partial-page updates, and are therefore not supported inside an UpdatePanel control.  You can refer the part of Controls that Are Not Compatible with UpdatePanel Controls of this link: http://www.asp.net/ajax/documentation/live/overview/UpdatePanelOverview.aspx

    If  you want to highlight the selected node in red, you can set the treeview's SelectedNodeStyle's forecolor is red,  for example: <SelectedNodeStyle ForeColor="Red" />

     

    Hope it helps.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Yours sincerely,
    Amanda Wang
    Microsoft Online Community Support
  • Re: Tree View to be refreshed with out screen refreshing???

    05-09-2008, 4:43 AM
    • Loading...
    • AxleWack
    • Joined on 10-02-2007, 4:56 AM
    • Posts 248

     

    Hey - Thanks Amanda Wang!

     

    I see that if the tree view is in the update panel, it even gives errors on the page..... thanks for refering me to the page to see which controls are not compatible with the update panel..... I will be using a differant approach.

     

    Thanks

Page 1 of 1 (4 items)