Reputation: 99
In a vb.net Windows Application, I have a datatable wich is not from a database. I want to add a new row, but when I add a new row only the new row is in the datatable, not the existing data.
dim dt as datatable treelist.datasource=dt this is existing item here in any event i want to add the new row in the datatable so that new node is added to the treelist
thanks for your help....
Upvotes: 0
Views: 21876
Reputation: 142
You should be able to declare a new row and add it to the DataTable as such:
'Create the new row
Dim newRow as DataRow = myTable.NewRow
'Add some data to it
newRow("columnName1") = data1
newRow("columnName2") = data2
'Add it to the table
myTable.Rows.Add(newRow)
'Bind the table
treeList.DataSource = dt
treeList.DataBind
That should work, just make sure you add the row to the DataTable before you bind it to the TreeView object.
Upvotes: 2