robjay
asked on
Cannot change ReadOnly property for the expression column
I have a data table which I add a boolean column to. When I later in the code try to change a value, I get an error that the column is read only.
dt.Columns.Add("Flag", GetType(Boolean), "False")
.
.
.
Later, in my code
dt.Rows(z)("Flag") = True ' ==> Errors - 'Flag' is read only
So, I tried to add ReadOnly = False in my column add code, but I get Cannot change ReadOnly property for the expression column error:
dt.Columns.Add("Flag", GetType(Boolean), "False").ReadOnly = False
dt.Columns.Add("Flag", GetType(Boolean), "False")
.
.
.
Later, in my code
dt.Rows(z)("Flag") = True ' ==> Errors - 'Flag' is read only
So, I tried to add ReadOnly = False in my column add code, but I get Cannot change ReadOnly property for the expression column error:
dt.Columns.Add("Flag", GetType(Boolean), "False").ReadOnly = False
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Just had to also add
Dim dc as New Data.DataColumn
Dim dc as New Data.DataColumn
DataColumn dtc = new DataColumn();
dtc.ColumnName = "Flag";
dtc.DataType = System.Type.GetType("Syste
dtc.ReadOnly = false;
dt.Columns.Add(dtc);