473,387 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

A very simple question about assigning a value

Hello,

I have the following case where I want to assign a value to a column
in a row. But it gives me an error that "Property Item is readonly":

DataAdapter.Fill(DataTable1)

Dim clone as DataTable

clone = DataTable1.Clone

For Each row As DataRow In
DataTable1.Select(String.Format("{0}='{1}'", field1, somevalue))

clone.ImportRow(row)

Next

clone.Rows.Item("field2") = "Test"
Here is the problem where it says "Property Item is readonly"

Your kind help will be really appreciated.

cheers

SY
Nov 22 '05 #1
4 1668
You have to do it this way:

clone.Rows(RowNumber)("field2") = "Test"

The "Rows" is the collection of all rows in the table (index starts at 0).
So you have to access one row in the way above by replacing "RowNumber" by
the number of the row in which you wanna assign the value to the field.

Regards,

Peter

"Sajid" <sa*********@yahoo.com> schrieb im Newsbeitrag
news:e0**************************@posting.google.c om...
Hello,

I have the following case where I want to assign a value to a column
in a row. But it gives me an error that "Property Item is readonly":

DataAdapter.Fill(DataTable1)

Dim clone as DataTable

clone = DataTable1.Clone

For Each row As DataRow In
DataTable1.Select(String.Format("{0}='{1}'", field1, somevalue))

clone.ImportRow(row)

Next

clone.Rows.Item("field2") = "Test"
Here is the problem where it says "Property Item is readonly"

Your kind help will be really appreciated.

cheers

SY

Nov 22 '05 #2
You have to do it this way:

clone.Rows(RowNumber)("field2") = "Test"

The "Rows" is the collection of all rows in the table (index starts at 0).
So you have to access one row in the way above by replacing "RowNumber" by
the number of the row in which you wanna assign the value to the field.

Regards,

Peter

"Sajid" <sa*********@yahoo.com> schrieb im Newsbeitrag
news:e0**************************@posting.google.c om...
Hello,

I have the following case where I want to assign a value to a column
in a row. But it gives me an error that "Property Item is readonly":

DataAdapter.Fill(DataTable1)

Dim clone as DataTable

clone = DataTable1.Clone

For Each row As DataRow In
DataTable1.Select(String.Format("{0}='{1}'", field1, somevalue))

clone.ImportRow(row)

Next

clone.Rows.Item("field2") = "Test"
Here is the problem where it says "Property Item is readonly"

Your kind help will be really appreciated.

cheers

SY

Nov 22 '05 #3
Ok this is easy.

Your trying to assign a value to a row position not the actual column, or
better the cell.

Off the top of my head:

clone.Rows[index].Columns[index].Text = "Test"

Mind you this syntax is probably wrong but you should get the idea.

Enjoy!!

-Evan

"Sajid" <sa*********@yahoo.com> wrote in message
news:e0**************************@posting.google.c om...
Hello,

I have the following case where I want to assign a value to a column
in a row. But it gives me an error that "Property Item is readonly":

DataAdapter.Fill(DataTable1)

Dim clone as DataTable

clone = DataTable1.Clone

For Each row As DataRow In
DataTable1.Select(String.Format("{0}='{1}'", field1, somevalue))

clone.ImportRow(row)
Ok
Next

clone.Rows.Item("field2") = "Test"
Here is the problem where it says "Property Item is readonly"

Your kind help will be really appreciated.

cheers

SY

Nov 22 '05 #4
Ok this is easy.

Your trying to assign a value to a row position not the actual column, or
better the cell.

Off the top of my head:

clone.Rows[index].Columns[index].Text = "Test"

Mind you this syntax is probably wrong but you should get the idea.

Enjoy!!

-Evan

"Sajid" <sa*********@yahoo.com> wrote in message
news:e0**************************@posting.google.c om...
Hello,

I have the following case where I want to assign a value to a column
in a row. But it gives me an error that "Property Item is readonly":

DataAdapter.Fill(DataTable1)

Dim clone as DataTable

clone = DataTable1.Clone

For Each row As DataRow In
DataTable1.Select(String.Format("{0}='{1}'", field1, somevalue))

clone.ImportRow(row)
Ok
Next

clone.Rows.Item("field2") = "Test"
Here is the problem where it says "Property Item is readonly"

Your kind help will be really appreciated.

cheers

SY

Nov 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: JKop | last post by:
Take the following simple function: unsigned long Plus5Percent(unsigned long input) { return ( input + input / 20 ); } Do yous ever consider the possibly more efficent:
5
by: disco | last post by:
I am working on this example from a book "C Primer Plus" by Prata 4th edition - p. 672. There is no erata on this problem at the publisher's website. 1) Is it a violation of copyright laws to...
13
by: na1paj | last post by:
here's a simple linked list program. the DeleteNode function is producing an infinit loop i think, but i can't figure out where.. #include <stdio.h> typedef struct { char *str; //str is a...
5
by: Rob Somers | last post by:
Hey all I am writing a program to keep track of expenses and so on - it is not a school project, I am learning C as a hobby - At any rate, I am new to structs and reading and writing to files,...
1
by: Tim | last post by:
I can't seem to figure out why this very simple linked list wont build.. I mean, there is no intelligence, just add to end. Anyway, please let me know if something i can do will make head (the...
6
by: lovecreatesbeauty | last post by:
/* It seems that when an int with width of four bytes is assigned to a one byte width char, the first three bytes from left to right are discarded and the rightest byte is assigned to that char....
73
by: Claudio Grondi | last post by:
In the process of learning about some deeper details of Python I am curious if it is possible to write a 'prefix' code assigning to a and b something special, so, that Python gets trapped in an...
30
by: Brian Elmegaard | last post by:
Hi, I am struggling to understand how to really appreciate object orientation. I guess these are FAQ's but I have not been able to find the answers. Maybe my problem is that my style and...
4
by: Armand | last post by:
Hi Guys, I have a set of array that I would like to clear and empty out. Since I am using "Array" not "ArrayList", I have been struggling in finding the solution which is a simple prob for those...
30
by: galiorenye | last post by:
Hi, Given this code: A** ppA = new A*; A *pA = NULL; for(int i = 0; i < 10; ++i) { pA = ppA; //do something with pA
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.