Thursday, March 22, 2007

ADO.NET musings (A control does not work directly with a DataTable . When you bind a control, a DataView is created and the controls interacts with..

Greg Robinson's Blog : AddNew vs. NewRow: "AddNew vs. NewRow

These 2 methods have confused me for a while. I assumed under the covers calls to AddNew created a new DataRow, marked as Detached, just like a call to NewRow does.

A control does not work directly with a DataTable . When you bind a control, a DataView is created and the controls interacts with the datatable through that view.

So, calls to AddNew are interacting with the DataView, not the DataTable. AddNew creates a new DataRowView

Public Overridable Function AddNew() As DataRowView

So, you will be working with a DataRowView, not a DataRow, on calls to AddNew."

No comments: