Feed on
Subscription

The implementation that form plan upholds in ASP.NET (3)



Three, revise, mobile burl dot
    accuses as a result of the server do not support a mouse to procrastinate use incident,Cannot move mobile node through procrastinating in that way like Windows program so,The kind that carries choice father node is here.Shift is through be being deleted in former position,Reposition adds implementation,Should notice to save node information first when delete.

Private Sub TreeView1_SelectedIndexChange(ByVal Sender As Object, byVal E As Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs) Handles TreeView1.SelectedIndexChange
Dim Dv As New DataView()Dv.Table = Ds.Tables("tree" )
Dim TmpNd As TreeNode = TreeNdSel(e.OldNode) , tmpNds As TreeNodeCollectionDv.RowFilter= "NODEID= "%26amp;TmpNd.IDDv(0)("NODE_DEscript") = Me.TextBox1.TextDv(0)("ADDRESS") = Me.TextBox2.TextDv(0)("TARGET") = Me.TextBox3.TextDv(0)("ICON") = Me.TextBox4.Text
If Dv(0)(%26quot;PARENTID%26quot;).ToString %26lt;%26gt;Me.DropDownList1.SelectedItem.Value Then
' mobile nodeDv(0)("PARENT_NAME") = Me.DropDownList1.SelectedItem.Value
If Me.DropDownList1.SelectedItem.Value = "ROOT" ThenTmpNds = TreeView1.Nodes
ElseTmpNds = FromIdToNode(Me.DropDownList1.SelectedItem.Value, treeView1.Nodes).Nodes ' the Nodes of new father node assembles
End If
GetNdCol(e.OldNode).Remove(tmpNd)TmpNds.Add(tmpNd)
End IfTmpNd.Text = Me.TextBox1.TextTmpNd.ImageUrl = Me.TextBox4.TextTmpNd = TreeView1.GetNodeFromIndex(TreeView1.SelectedNodeIndex)Dv.RowFilter= "NODEID= "%26amp;TmpNd.ID
Me.TextBox1.Text = Dv(0)("NODENAME").ToString
Me.TextBox2.Text = Dv(0)("ADDRESS").ToString
Me.TextBox3.Text = Dv(0)("TARGET").ToString
Me.TextBox4.Text = Dv(0)("ICON").ToString
End Sub
Private Function FromIdToNode(ByVal ID As String, byVal Nds As TreeNodeCollection) As TreeNode
' search node by key word
Dim I As Integer
Dim TmpNd As TreeNode, tmpNd1 As TreeNode
For Each TmpNd In Nds
If TmpNd.ID = ID Then
Return TmpNd
Exit Function
End IfTmpNd1 = FromIdToNode(ID, tmpNd.Nodes)
If Not (tmpNd1 Is Nothing) Then
Return TmpNd1
Exit Function
End If
Next
Return Nothing
End Function

Four, last word

The basic method that     above elaborates shape of the tree in ASP.NET to show,And if where to undertake maintenance to cultivating node (increase, delete, revise, mobile) while,Modification database data.Be restricted as a result of length place,The author is mixed to main train of thought only here flow and crucial step made the introduction,Not listed and detailed source code,The reader can be perfected by oneself.The person that need detailed source code can be contacted with me,Article program is debugged below VS.NET, SQLServer, Windows 2000, IIS5.0 through. ...

The implementation that form plan upholds in ASP.NET (2)



Two, increase, delete burl to nod
    is pure increase on Treeview, delete, the Add that modification node needs to use Nodes property only, Remove, wait for a method can,The distinction in the Nodes gather that notable place is the Treeview in VS.NET and VS6.0,In VS6.0 is a big rally,And in VS.NET is every Node issues storied to have Nodes property.Increase, delete, when modification burl is nodded, with VS6.0 photograph comparing has very big difference,When be being deleted especially.

Private Sub ButAdd_Click(ByVal Sender As System.Object, byVal E As System.EventArgs) Handles ButAdd.Click ' add below the node of make choice of child node
Dim TmpNd As New TreeNode() , ndSel As TreeNodeTmpNd.ID = GetNewId()
NdSel = TreeView1.GetNodeFromIndex(TreeView1.SelectedNodeIndex) ' the node of pitch onNew node of TmpNd.Text = " "
NdSel.Nodes.Add(tmpNd)
Dim MyRow As DataRowMyRow = Ds.Tables("tree").NewRow()MyRow("NODE_NAME") = TmpNd.IDNew node of MyRow("NODE_DEscript") = " "%26amp;TmpNd.ID%26amp;"_ "%26amp;NdSel.IDMyRow("PARENT_NAME") = NdSel.IDDs.Tables("tree").Rows.Add(myRow)
End Sub
Private Sub ButDele_Click(ByVal Sender As Object, byVal E As System.EventArgs) Handles ButDele.Click ' the node that deletes pitch on
Dim Idx As String = TreeView1.SelectedNodeIndex()
GetNdCol(idx).Remove(TreeView1.GetNodeFromIndex(idx) )
Dim Dv As New DataView() , recNo As IntegerDv.Table = Ds.Tables("tree" )Dv.RowFilter= "NODEID= "%26amp;NdIdDv.Delete(0)
End Sub
Private Function GetNdCol(ByVal Idx As String) As TreeNodeCollection
' the Nodes of the father node that obtains pitch on node assembles
Dim Cnt As Integer, I As Integer
Dim TmpNds As TreeNodeCollection
Dim Idxs() As StringIdxs = Split(idx, ". Cnt = UBound(idxs)
If Cnt = 0 ThenTmpNds = TreeView1.Nodes
ElseTmpNds = TreeView1.Nodes(CInt(idxs(0))).Nodes
For I = 1 To Cnt - 1TmpNds = TmpNds(CInt(idxs(i))).Nodes
Next
End If
Return TmpNds
End Function...

The implementation that form plan upholds in ASP.NET (1)



The data that cultivates contrast figure to be used at showing according to the tree shape structure has an organization,Its use is more extensive,The file system in be like the computer (the resource management in Windows implement) , the compositive structure of enterprise or company.We know below Windows the tool such as VB, PB, Delphi provided a function very strong tree accuse a TreeView,Use Treeview to accuse can develop tree form to pursue conveniently.It is so not easy to uphold form plan in the implementation on the webpage however,In the Internet Explorer WebControls that Microsoft uses to offer in ASP.NET it makes now the development of tree contrast figure on the webpage and the convenience like falling in Windows,Same function is powerful,More agile even.

The method that   Introduction   article upholds form plan with development of Internet Explorer WebControls,Because texture of tree contrast figure is more complex,Use rise to often do not know how to do it.The applied Program Manager that the author combines to just used ASP.NET to write for the company recently this one specific example,Elaborate in detail how to rise the use of Internet Explorer WebControls and database connection below ASP.NET,Random of implementation data cent is multilayer show,Undertake addition conveniently, revise, delete, mobile operation.The author hopes to pass pair of this example elaborate,The result that achieves cast a brick to attract jade-offer a few commonplace remarks by way of introduction so that others may come up with valuable opinions,With everybody the colleague communicates each other,Collective progress.

    Internet Explorer WebControls is not in the standard Server Control of VS.NET,The download on the site that wants Microsoft,Downloading an address is:Http://msdn.microsoft.com/downloads/samples/internet/default.asp? When the first time after Url=/Downloads/samples/Internet/ASP_DOT_NET_ServerControls/WebControls/default.asp downloads installation is used,Should right attack kit Customize Toolbox... the pitch on after Micosoft.Web.UI.WebControls.Treeview is being found in → .NET Framework Components,Such Treeview accuse appeared in kit.

    one, of the tree build

    specific means is:Found a database,News of design tree picture expresses TREE_INFO,Include field of NODEID, PARENTID, NODENAME, ADDERSS, ICON,Other field is decided according to real business,Node name NODENAME will be in tree accuse show on node,The only label mark that NODEID field saves node,The father node sign that PARENTID shows current node,Label name comprised " catenary is expressed " ,The structure that recorded the node on the tree.Design body of window of a Web places TreeView to accuse on its.






Private Sub CreateDataSet() ' establish data set
Dim MyConn As New SqlConnection()
Dim MyCmd As New SqlCommand("select NODEID, NODENAME, PARENTID, ADDRESS, ICON From Tree_info" , myConn)
Dim MyDataAdapter As New SqlDataAdapter()MyConn.ConnectionString = Application("connectstring" )MyCmd.CommandText = " "MyCmd.Connection = MyConnMyDataAdapter.SelectCommand = MyCmdMyDataAdapter.Fill(ds, "Tree" )
End Sub

The main train of thought that     makes a contribution is:Begin from root node recursive call show child tree




Private Sub Page_Load(ByVal Sender As System.Object, byVal E As System.EventArgs) Handles MyBase.Load
CreateDataSet()IntiTree(TreeView1.Nodes, 0)
End Sub
Private Sub IntiTree(ByRef Nds As TreeNodeCollection, byVal ParentId As Integer)
Dim Dv As New DataView()
Dim Drv As DataRowView
Dim TmpNd As TreeNode
Dim IntId As IntegerDv.Table = Ds.Tables("tree" )Dv.RowFilter = "PARENTID= ' "%26amp;ParentId%26amp;"' "
For Each Drv In DvTmpNd = New TreeNode()StrId = Drv("NODE_ID" )TmpNd.ID = StrIdTmpNd.Text = Drv("NODE_NAME " )TmpNd.ImageUrl = Drv("ICON").ToString
Nds.Add(tmpNd)IntiTree(Nds(Nds.Count - 1).Nodes, intId)
Next
End Sub...

In two notable places in ASP.NET



The place that there are two to make a person strange in the Page_Load incident of page of the ASPX in ASP.NET,You should remember them:
A. Sometimes Page_Load incident can happen for many times in your ASP.NET page.A possible reason of this kind of circumstance happening is your AutoEvenWireup ASPX page value setting became True.If so,So be in " Sub Page_Load(ByVal Sender As System.Object, byVal E As System.EventArgs " from the back add " Handles MyBase.Load " this group is done not have namely necessary.Since Visual Studio.NET can be you automatically to treat this share,You can set AutoEventWireup value False of course.
B. Be like to press button sometimes click incident to process code and did not move.You should check Page_Load incident to ensure here the code of any to load data (issueing the code that calm data ties in drawing list for example) be in only initiative to load this page when move,is not move when the client carries data to return later.A simple method that examines this kind of case is the test that pair of Page.IsPostBack costs add in the function of Page_load incident processing in you - False means this is a page by to load True meant first time to had produced data to return a process....

Raise the method of ASP.NET function