• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

Dynamcally populating a TreeView

Could someone tell me what's wrong with my code?

im trying to do what the title of the post says.....

However, on the line

Dim row As New Data.DataRow

I get the following error

'System.Data.DataRow.Protected Sub New(builder As System.Data.DataRowBuilder)' is not accessible in this context because it is 'Protected'.      

What's wrong? How do I declare a row??


Private Sub FillCustomers(ByVal parent As TreeNode)
        Dim conn As New SqlConnection("Data Source=DAODEVBOX;Initial Catalog=suds_prototype;User ID=sa;Password=***")
        Dim ds As New Data.DataSet()
        Dim da As New SqlDataAdapter("select * from Categories", conn)
        da.Fill(ds, "Category")
        Dim row As New Data.DataRow
        For Each row In ds.Tables("Category").Rows
            Dim node As TreeNode = New TreeNode()
            node.Text = row("companyname").ToString()
            node.Value = row("customerid").ToString()
            node.PopulateOnDemand = True
            node.SelectAction = TreeNodeSelectAction.SelectExpand
    End Sub

Open in new window

1 Solution
dont use New in your Row-declaration,

Dim row as Data.DataRow

because you are getting the row instance in the loop, and declaring it with new needs parameters.
bdb12Author Commented:
arggh! ok great thank you....

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now