Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
Can anybody tell me the C# euivalent of the VB statement Below.
C#
treeView.Nodes.AddAt(0, nodes.Item[index]);

The error i am getting while buiding the page is
'System.Web.UI.WebControls.TreeNodeCollection' does not contain a definition for 'Item' and no extension method 'Item' accepting a first argument of type 'System.Web.UI.WebControls.TreeNodeCollection' could be found (are you missing a using directive or an assembly reference?)

Thanks In Advance,
Reeogeo
Posted
Updated 17-Oct-11 20:12pm
v3
Comments
Mycroft Holmes 18-Oct-11 2:18am    
Does intellisense not work on your machine, try .items[index]. Just a guess.

It would also be useful to know what tech you are using, winforms, asp or other.
reogeo2008 18-Oct-11 2:22am    
Hello,

This is my function which i have converted from VB
and i tried the same u mentioned above and getting the same error

public static void RestoreTreeView(TreeView treeView ,String key)
{
if( IsTreeViewStateSaved(treeView, key) )
{
treeView.Nodes.Clear();

TreeNodeCollection nodes = (TreeNodeCollection)HttpContext.Current.Session[key + treeView.ID];
for( int index = nodes.Count - 1;index>=0;index--)
{
treeView.Nodes.AddAt(0, nodes.Item[index]);
}

HttpContext.Current.Session[key + treeView.ID] = null;
}
}

1 solution

Try
C#
treeView.Nodes.AddAt(0, nodes[index]);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900