Solved

Cannot change ReadOnly property for the expression column

Posted on 2009-07-02
3
2,082 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
Comment Utility
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
Comment Utility
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
Comment Utility
Just had to also add
Dim dc as New Data.DataColumn
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now