Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error Adding Nodes To TreeView
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01451867
Message ID:
01451928
Views:
19
>I'm trying to load a treeview. This code works in WinForms. In ASP I get the compile time error
>
>
>'System.Xml.Linq.Extensions.Nodes<T>(System.Collections.Generic.IEnumerable<T>)' is a 'method', 
>which is not valid in the given context
>
>
>
>Here's my code. It's erroring on "nodRoot.Nodes.Add(nodReport)" inside the ELSE.
>
>private void _LoadReportNodes()
>{
>    string Command = "SELECT * FROM ApexReports ORDER BY ParentId, Sequence";
>    DataSet dsTreeNodes = DataLayer.ExecuteQuery(Command);
>
>    string ReportTitle = string.Empty;
>    TreeNode nodRoot = null;
>    TreeNode nodReport = null;
>
>    foreach (DataRow Row in dsTreeNodes.Tables[0].Rows)
>    {
>        ReportTitle = Row["ReportTitle"].ToString();
>
>        if (Row["ParentId"] != DBNull.Value)
>        {
>            nodRoot = new TreeNode(ReportTitle);
>            tvwReports.Nodes.Add(nodRoot);
>        }
>        else
>        {
>            nodReport = new TreeNode(ReportTitle);
>            nodRoot.Nodes.Add(nodReport);
>        }
>    }
>}
>
>
See docs. The TreeView has a Nodes collection. For a TreeNode it's ChildNodes:
nodRoot.ChildNodes.Add(nodReport);
But you've still got a problem since nodRoot has not been instantiated. And wouldn't you want to add the child node from the table to an existing root node ?
Previous
Reply
Map
View

Click here to load this message in the networking platform