Replacing values in a datatable
- From: jhcorey@xxxxxxxxx
- Date: 29 Aug 2005 08:20:03 -0700
I'm looking at some code where a column was added to a datatable and
then given
a value. It works fine. But if I try to update a previously existing
column,
it doesn't take. No error is thrown, it just doesn't get updated.
I've tried
a few variations, and I'm trying to avoid creating a new datatable.
An example of what works and what doesn't is shown below.
Any quick and easy solutions?
myDataTable.Columns.Add("Class",
System.Type.GetType("System.String"))
myDataTable.Columns("Class").AllowDBNull = True
For Each myDataRow In myDataTable.Rows
'OK
myDataRow("Class") = CType(myDataRow("CATG_NUM"),
String).Substring(0, 2)
'Not Ok -- it doesn't get updated
myDataRow("CATG_NUM") = myString
Next
.
- Prev by Date: Re: DataGrid Delete ButtonColumn
- Next by Date: Re: onLoad Javascript
- Previous by thread: Attachements for SMTP mail
- Next by thread: Object reference not set to an instance of an object
- Index(es):