Last post Aug 25, 2015 03:45 AM by Weibo Zhang
Aug 24, 2015 12:01 PM|werice|LINK
I have added a new column to a dataset and am trying to update the column and I get the error Property item is READONLY.
Below is the code I am using why is this not correct.
am I getting the error: Property item is READONLY.
Aug 24, 2015 01:06 PM|fadi hanna|LINK
try both of these suggestions and see who would work with you
1- set the readonly property to false :
foreach (System.Data.DataColumn col in tab.Columns) col.ReadOnly = false;
2- if you are using the datatable to fill a gridview for example you Have to use the cellbegin edit to make the cell readonly property to true. .
private void dataGridView1_CellBeginEdit(object sender,DataGridViewCellCancelEventArgs e)
if (dataGridView1.Columns[e.ColumnIndex].Name == "ColName0")
// you can check whether the read only property of that cell is false or not
try both and if you found this was useful don't forget to mark as answered
Aug 25, 2015 03:45 AM|Weibo Zhang|LINK
My understanding of your code above is below, if I’m wrong, please let me know.
You want to add a new column named “fullname” to DataSet “m_dsContact”,
then you want to set the new column value equals the column “First_Name” in the Foreach loop. If I’m right, I think you could just refer to the following code to use the instance
“Row” in each loop.
For Each Row As DataRow In m_dsContact.Tables(0).Rows
Row ("fullname") = Row ("RegionID")
Besides, the “m_dsContact.Tables(0).Rows” gets
the collection of rows that belong to this table, there’s no property named “Item” in the collection. For more things, you could take a look at the following link.
I hope it’s useful to you.