DataTable C# Empty column type
- by Dested
I am trying build a DataTable one row at a time using the following code.
foreach (var e in Project.ProjectElements[hi.FakeName].Root.Elements()) {
index = 0;
object[] obj=new object[count];
foreach (var holdingColumn in names) {
string d = e.Attribute(holdingColumn.Key).Value;
obj[index++] = d;
}
dt.Rows.Add(obj);
}
The problem is the DataTable has types tied to the columns. Sometimes im passing null (or an empty string) in that object index and it is telling me that it cant be converted properly to a DateTime (in this case). My question is what should I default this value to, or is there some way to have the DataTable ignore empty values.