tags:

views:

313

answers:

1

Hi, I have a question about the datarow and how I can update it...

I have a datatable with two columns, id and name. I do the following:

    // data table has data at this point....

    myTable.Columns.Add("Fri");

    foreach(DataRow r in myTable.Rows) {
        r["Fri"] = 4;

    }

What I am trying to do here is add a new columnm, "Fri". Then for each entry already in the data table I want to have the value in column Fri as 4. Thanks for the help.

+1  A: 

The code you listed should work, but if you want to later use the Fri value as an integer you should declare the data type of the column like this:

myTable.Columns.Add("Fri", typeof(int));
CodeMonkey1
Maybe something else is wrong in the code above.
Gerrie Schenck