Reputation: 59
iam looking into datatable and fetching line by line,
iam having 50 length values. i want to assign 10th length value as "text".
but it is not stored in datarow after assigned
foreach (DataRow row in dtSource.Rows)
{
if (row.ItemArray[17].ToString().Length > 32)
{
string ss= "text";
row.ItemArray[17] = ss; // here it is not added in itemarray
}
}
Upvotes: 2
Views: 1045
Reputation: 460108
DataRow.ItemArray
creates a new array on the fly that contains all fields. So when you modify this array you won't modify the DataRow
itself. You should use the DataRow
indexer:
row[17] = ss;
You can use ItemArray
when you need all objects in an array or when you want to assign the whole row's fields at once by assigning an array to this property.
Upvotes: 10