Solved

Cannot change ReadOnly property for the expression column

Posted on 2009-07-02
3
2,295 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

696 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