I have a datatable, transformersDT, populated with data from a database table. I’d like to check the value in a particular cell (row 0, column 6) and change that value based on what I find. How can I accomplish this in C#?
For instance, if the value is “0002” then I’d like to change it to “Conventional”. Basically, I’m trying to make the values more “human readable” when viewed on the screen.
I’m trying to do something like this:
if (transformerDT.Rows[0][6] == "0002")
{
transformerDT.Rows[0][6] = "Conventional";
}
You’re close:
You correctly referenced the row and column but you needed to cast the cell’s content to a string before you run your comparison.