Link to home
Start Free TrialLog in
Avatar of robjay
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

ASKER CERTIFIED SOLUTION
Avatar of jbeasle3
jbeasle3
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Add datacolum like this:
DataColumn dtc = new DataColumn();
            dtc.ColumnName = "Flag";
            dtc.DataType = System.Type.GetType("System.Boolean");
            dtc.ReadOnly = false;
            dt.Columns.Add(dtc);
Avatar of robjay
robjay

ASKER

Just had to also add
Dim dc as New Data.DataColumn