Reputation: 16067
I need to edit the text of a DataGridViewCell. To be specific, I need to change the text from -1
to "N/A"
First I tried this:
dgResults.Rows[0].Cells[0].Value = "N/A";
But it complained at runtime:
After that, I tried changing the datatype of the column:
dTable.Columns[0].DataType = System.Type.GetType("System.String");
and I get this error:
Cannot change DataType of a column once it has data.
I have no access to the database and cannot modify it.
Upvotes: 1
Views: 3462
Reputation: 73283
Why are u changing datatype of datatable? Why not change column type of dgv? try this:
dgResults.Columns[0].ValueType = typeof(string);
dgResults.Rows[0].Cells[0].Value = "N/A";
Use appropriate column index
Upvotes: 0