Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
710
Delete node from a databound tree
posted

I have a tree databound to a DataSet.

When the user selects the Delete command (in a toolbar), I am trying to delete the selected node. So, I execute the following code:

((DataRowView)treeHierarchy.ActiveNode.ListObject).Row.Delete();

The row dissappears from the treeview as expected. But, later whenever I attempt to commit the changes to the DataSet to the database, the DataRow is "Unchanged". I noticed that after the statement above is executed, the RowState of the DataRow is still "Unchanged".  

What am I missing here?

  • 710
    posted

    Yep, I am retarded. I was looking at the wrong row.

     

  • 469350
    Verified Answer
    Offline posted

    Hi,

    What you are describing does not seem possible. If the RowState has not changed, then why would the row disappear from the tree? Also, since you are deleting the row directly on the data source, the tree really has nothing to do with your question, does it?

    What happens if you do the same thing without even using the tree?

    I just tested this out in a small sample project and RowState is Deleted, just like it should be. My guess is that your code is somehow looking at the wrong row or the wrong DataSet/DataTable.