views:

22

answers:

2

How do you create DataRow instances that aren't tied to any particular DataTable instance?

(EDIT: I know you can create DataRows using the DataTable.NewRow() method, but the problem is that I can't seem to disconnect the row from its parent table so I can pass the individual row around without having to pass the entire table around)

A: 

I rather would only copy the content of the DataRow. You can achive that with:

row.ItemArray

I think that would be a better approch, than trying to get a workaround for the lacking copy functionality.

BitKFu
+1  A: 

One thing you could try is deleting it immediately:

DataRow row = table.NewRow();
row.Delete();

That will put it in a DataRowState of Detached, which sounds like what you want. I'm not sure what you're trying to achieve in terms of a bigger picture though, so this may not help.

Jon Skeet