Solved

Cannot change ReadOnly property for the expression column

Posted on 2009-07-02
3
2,209 Views
Last Modified: 2012-06-21
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

0
Comment
Question by:robjay
3 Comments
 
LVL 3

Accepted Solution

by:
jbeasle3 earned 500 total points
ID: 24768794
Try doing this:  it seems to work where entering the expression in the add function doesn't

dc = New DataColumn("Flag", GetType(Boolean))
dc.DefaultValue = False
dt.Columns.Add(dc)
.
.
dt.Rows(0)("Flag") = True
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24768881
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);
0
 

Author Closing Comment

by:robjay
ID: 31599404
Just had to also add
Dim dc as New Data.DataColumn
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question