Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Cannot change ReadOnly property for the expression column

Posted on 2009-07-02
3
Medium Priority
?
2,414 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

604 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