tree

G

Guest

Hi to all
I have tree web controls with 3 level nodes
when i create 2 level nodes thers is no problem but when i add the thired
level
this erreur occurs :

Exception Details: System.ArgumentOutOfRangeException: Specified argument
was out of the range of valid values. Parameter name: Index was out of range.
Must be non-negative and less than the size of the collection.

My code :While i < ds.Tables(0).Rows.Count
parentNode = New TreeNode()
parentNode.Text = ds.Tables(0).Rows(i).Item(0)
tree.Nodes.Add(parentNode)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
GAdaraID = ds.Tables(0).Rows(i).Item(1)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''
j = 0
While j < ds.Tables(1).Rows.Count
AdaraID = ds.Tables(1).Rows(j).Item(1)

If AdaraID = GAdaraID Then
childNode = New TreeNode()
childNode.Text = ds.Tables(1).Rows(j).Item(0)
tree.Nodes(i).Nodes.Add(childNode)
End If
KAID = ds.Tables(1).Rows(j).Item(2)
h = 0

While h < ds.Tables(2).Rows.Count
KID = ds.Tables(2).Rows(h).Item(1)
If KID = KAID Then
CChildNode = New TreeNode()
CChildNode.Text = ds.Tables(2).Rows(h).Item(0)
tree.Nodes(i).Nodes(j).Nodes.Add(CChildNode)

End If
h += 1

End While 'end h
j += 1

End While ''end j
i += 1

End While 'end i

////////////////////////////////////
any ideas ??
thanks
 
G

Guest

Hi,

Carefully note the following line. (You have to add "-1" to the count)
Because you start from 0 and move to the last.

Prakash.C

While i < ds.Tables(0).Rows.Count -1
parentNode
 
G

Guest

Thanks a lot Prakash

Prakash.NET said:
Hi,

Carefully note the following line. (You have to add "-1" to the count)
Because you start from 0 and move to the last.

Prakash.C

While i < ds.Tables(0).Rows.Count -1
parentNode
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top