CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML





Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 10/31/2007 8:03:07 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 15 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
2 Items, 1 Pages 1 |< << Go >> >|
griff303
Asp.Net User
Treeview not refreshing on autopostback10/31/2007 8:03:07 PM

0/0

I have a tree menu on the page that loads fine on the initial page load along with a dropdownlist that autopostback's with a new usertype. With that usertype I populate the tree again with the appropriate menu(well its suppose to), but it only runs the intial root level and doesn't fill in the rest.

 

<asp:DropDownList ID="roleDDL" AutoPostBack="true" runat="server">
            </asp:DropDownList><br />
            <div style="border:solid 0px #ff0000;background:#ffffff;color:#ffffff; width : 100%; height : 350px; overflow : auto; ">
            <asp:TreeView ID="TreeView3" ExpandDepth="FullyExpand" ShowCheckBoxes="All" RootNodeStyle-ImageUrl="~/images/computer.gif" ParentNodeStyle-ImageUrl="~/images/folder.gif" PopulateNodesFromClient="true" ShowLines="true" ShowExpandCollapse="false" runat="server">
                <NodeStyle Font-Names="Arial" Font-Size="8pt" ForeColor="DarkBlue" HorizontalPadding="5"/>
                <RootNodeStyle Font-Bold="True" Font-Size="9pt"/>
                <HoverNodeStyle Font-UnderLine="True" />
            </asp:TreeView>

  If Not Page.IsPostBack Then
                Buffer = True
                populateRoleDDL()
                PopulateRootLevel2()
                'Panel1.visible = False
                TreeView1.Visible = True
                TreeView3.Visible = True

End If

 

Private Sub PopulateRootLevel2()

        Dim dbConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("LocalSqlServer").ConnectionString)
        'Dim myCommand As New SqlCommand("prcGetNodesByUserTypeID", dbConnection)
        Dim myCommand As New SqlCommand("select id,name,(select count(*) FROM tblNode WHERE parentid=sc.id) childnodecount FROM tblNode sc where parentID IS NULL", dbConnection)
        'myCommand.CommandType() = Data.CommandType.StoredProcedure
        'myCommand.Parameters.Add("@UserTypeID", SqlDbType.Int).Value = 1

        Dim da2 As New SqlDataAdapter(myCommand)
        Dim dt2 As New DataTable()
        da2.Fill(dt2)

        PopulateNodes2(dt2, TreeView3.Nodes)

        dbConnection.Close()
        myCommand.Dispose()

    End Sub

    Private Sub PopulateNodes2(ByVal dt2 As DataTable, ByVal nodes2 As TreeNodeCollection)

        For Each dr2 As DataRow In dt2.Rows
            Dim tn2 As New TreeNode()
            tn2.Text = dr2("Name").ToString()
            tn2.Value = dr2("ID").ToString()
            'tn2.NavigateUrl = "folderfilecleanup.aspx?gip=" & dr2("ID").ToString()
            tn2.SelectAction = TreeNodeSelectAction.None
            'tn2.Target = "menuSelectB"
            'tn.ShowCheckBox = True
            'tn.Checked = True
            tn2.Target = "_self"
            'tn2.SelectAction = TreeNodeSelectAction.Expand
            nodes2.Add(tn2)

            'If node has child nodes, then enable on-demand populating
            tn2.PopulateOnDemand = (CInt(dr2("childnodecount")) > 0)
        Next

    End Sub

    Private Sub PopulateSubLevel2(ByVal parentid2 As Integer, ByVal parentNode2 As TreeNode)

        Dim tempUserTypeID As Integer
        tempUserTypeID = 1

        Dim dbConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("LocalSqlServer").ConnectionString)
        'Dim objCommand As New SqlCommand("select id,name,(select count(*) FROM tblNode WHERE parentid=sc.id) childnodecount FROM tblNode sc JOIN where parentID=@parentID and ", dbConnection)
        Dim objCommand As New SqlCommand("select sc.id,sc.name,(select count(*) FROM tblNode tan WHERE tan.parentid=sc.id) childnodecount FROM tblNode sc JOIN tblNodeUserType tut ON tut.NodeID = sc.ID WHERE sc.parentID=@parentID and tut.UserTypeID = @UserTypeID and sc.Active=1", dbConnection)
        objCommand.Parameters.Add("@parentID", SqlDbType.Int).Value = parentid2
        'If roleDDL.SelectedValue = "Choose a Type" Then
        '    objCommand.Parameters.Add("@UserTypeID", SqlDbType.Int).Value = 0
        'Else
        '    objCommand.Parameters.Add("@UserTypeID", SqlDbType.Int).Value = Session("usertypeid") 'roleDDL.SelectedValue
        'End If

        objCommand.Parameters.Add("@UserTypeID", SqlDbType.Int).Value = roleDDL.SelectedValue ' Session("usertypeid")

        Dim da2 As New SqlDataAdapter(objCommand)
        Dim dt2 As New DataTable()
        da2.Fill(dt2)
        PopulateNodes2(dt2, parentNode2.ChildNodes)

    End Sub

    Private Sub TreeView3_TreeNodePopulate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles TreeView3.TreeNodePopulate

        PopulateSubLevel2(CInt(e.Node.Value), e.Node)

    End Sub

 

 

 Protected Sub roleDDL_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles roleDDL.SelectedIndexChanged
        TreeView3.Nodes.Clear()
        PopulateRootLevel2()
    End Sub


- km

______________________________________

"always here and always forever"
Johnson2007
Asp.Net User
Re: Treeview not refreshing on autopostback11/2/2007 5:33:13 AM

0/0

The code in If Not Page.IsPostBack Then statement will not be executed when the page is postback by the dropdownlist's postback.


Johnson
2 Items, 1 Pages 1 |< << Go >> >|



Search This Site:


Meet Our Sponsors:



Other Resources:

Refresh Treeview on Postback - newsgroup.asp-net-forum.general_asp-net ... I've tested the treeview using the textbox autopostback and it doesn't always ... code behing not working. web site admin tool problem. microsoft sql server smo ...
Page refreshing when autopostback is false ... u set autopostback is false it wont haapen.that is true.that is not a browser problem also. ... Previous : tree view in asp.net. Return to Discussion Forum ...
Asp.Net 2.0 Treeview - How to AutoPostback when a TreeNode's checkbox ... if you find the the treeview could not PostBack, I am afraid you should require javascript. ... Asynchronous postbacks and refresh only the Treview control, it ...
Controls not refreshing in pageview - telerik Forum Treeview for WinForms. UI Controls for WinForms. Themes and Visual Style Builder ... AutoPostBack="True" SelectedIndex="0"> <Tabs> ...
obout inc - Free ASPTreeView - Treeview - Server to client without ... Cross-browser. - Treeview - Server to client without refreshing page ... AutoPostBack with various options. Open in Search pane. Move nodes by clicking a button ...
TheMSsForum.com >> Ado >> TreeView - The Microsoft Software Forum ... Refresh End If Else MsgBox("Your user name is not correct") End If ... "20px" BackColor="8454016" ForeColor="black" AutoPostBack="true" DataSourceID ...
CodeProject: ASP.NET TreeView Control & the Client's Browser. Free ... NodeData is not a property of TreeView in ASP.NET 2.0, and after reading all the ... I want to disable (AutoPostBack) for the tree . So on the ...
ASP.net Web Controls [Archive] - HighTechTalks DotNet Forums Object Not Referece not set on a Label control (1 replies) ... IEWC:Treeview, automatically check subnodes without AutoPostBack (2 replies) ...



 
All Times Are GMT