C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Databinding »

Tree databinding in vb.net and sql 2005


Posted Date: 09 Oct 2009    Resource Type: Code Snippets    Category: Databinding
Author: Amol H. KagdeMember Level: Gold    
Rating: 1 out of 5Points: 7



Tree databinding in vb.net and sql 2005


Private Sub PopulateTree()
Dim strSql As String
Dim strMenuDesc As String
Dim strMenuString As String
Dim strMenuType As String
Dim dr As SqlClient.SqlDataReader
Dim ndParent As TreeNode
Dim ndChild As TreeNode
trvBalSheetMaster.Nodes.Clear()
'strSql = "select Id,description,parentid from acc_balsheetmaster where id not in (select balsheetinedx_id from Acc_balsheetschedulemappingMaster)order by id"
'dr = NewDataReader(strSql)
dr = NewDataReaderByProc("acc_balsheettreebind")
While dr.Read
If dr.Item("parentid") = 0 Then
strMenuDesc = dr.Item("description")
ndParent = New TreeNode(strMenuDesc)
ndParent.Tag = dr.Item("id")
If Convert.ToInt16(dr.Item("id")) = 0 Then
ndParent.ImageIndex = dr.Item("id").ToString().Trim()
Else
ndParent.ImageIndex = Convert.ToInt16(dr.Item("id"))
End If
trvBalSheetMaster.Nodes.Add(ndParent)
Else
strMenuDesc = dr.Item("description")
ndParent = getNodeByTag(dr.Item("parentid"), trvBalSheetMaster.Nodes)
ndChild = ndParent.Nodes.Add(strMenuDesc)
ndChild.Tag = dr.Item("id")
If Convert.ToInt16(dr.Item("id")) = 0 Then
ndChild.ImageIndex = dr.Item("parentid").ToString().Trim()
Else
ndChild.ImageIndex = Convert.ToInt16(dr.Item("id"))
End If
End If
blnFind = False
End While
dr.Close()
End Sub
Private Function getNodeByTag(ByVal pStrTag As String, ByVal pTrNode As TreeNodeCollection) As TreeNode
Dim tNode As TreeNode
Dim retNode As TreeNode
For Each tNode In pTrNode
If tNode.Tag = pStrTag Then
retNode = tNode
blnFind = True
ElseIf tNode.Nodes.Count <> 0 And blnFind = False Then
retNode = getNodeByTag(pStrTag, tNode.Nodes)
End If
Next
getNodeByTag = retNode
End Function



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Tree databinding  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: DataBase Operation In Java Using JDBC
Previous Resource: Binding the table item into the treeview
Return to Discussion Resource Index
Post New Resource
Category: Databinding


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use