I have a list of strings and am in need of converting it to a Datarow. I tried
toReturn.Add("UserID");
toReturn.Add("UserName");
DataRow row = null;
row.ItemArray=toreturn.ToArray();
This is throwing me an exception
Object reference not set to an instance of an object.
So i tried with
DataRow Row=new DataRow();
That is also not allowed.Can somebody help me in this.
DataRow
s can only exist with a DataTable
.
Create a DataTable
with appropriate columns, then call table.Rows.Add(list.ToArray())
.
However, you probably shouldn't be using DataRow
in the first place.