1

I have a DataTable that I'm exporting to pdf and there are numeric value like status id that I want to change to strings for example:

dataRow["statusId"] = 1; //dataRow["statusId"] type is int

and I want it to be:

dataRow["statusId"] = "Open file";

How can I do it without coping the entire data table ?

Liran Friedman
  • 4,027
  • 13
  • 53
  • 96

1 Answers1

0

You actually can't do it. The best way is to actually clone the dataTable and then copy each row:

DataTable dtCloned = dt.Clone();
dtCloned.Columns[0].DataType = typeof(Int32); //in the column you actually need.
foreach (DataRow row in dt.Rows) 
{
    dtCloned.ImportRow(row);
}

Source: How To Change DataType of a DataColumn in a DataTable?

Community
  • 1
  • 1
Miquel Coll
  • 759
  • 15
  • 49