tatton777
asked on
I need to iterate through a DataTable and change data conditionally
I have a instantiated, loaded, DataTable with the following columns:
FeeID
FeeGroup
Comment
Price
I need to itereate through the table and anytime that FeeGroup = "R" I want that field changed to "Required".
Can anyone help?
FeeID
FeeGroup
Comment
Price
I need to itereate through the table and anytime that FeeGroup = "R" I want that field changed to "Required".
Can anyone help?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes, sorry that I forgot about the ToString().
> The ReadOnly property on the TableColumn must be set to "false".
Well, that should be fairly obvious :)
Glad I could help,
woolf
> The ReadOnly property on the TableColumn must be set to "false".
Well, that should be fairly obvious :)
Glad I could help,
woolf
ASKER
foreach (DataRow r in dataTable.Rows)
{
if (r["FeeGroup"].ToString() == "R")
{
r["FeeGroup"] = "Required";
}
}
Just a note to anyone else who might be trying this. The ReadOnly property on the TableColumn must be set to "false".
THANKS WLFS!!