Hey all need a lil help sorting a loop for this table out, cant seem to apply a working example to the model, anyway here it goes.
I have 2 datatables, each with different data and different values, the only value in common is the date. The first table has everything I want in it except a single column of values (from the other table) So I need to merge this column onto the first table, not all the other data with it.
So ideally I'd like something that looks like this:
DataTable tbl1; //Assume both are populated
DataTable tbl2;
tbl1.Columns.Add("newcolumnofdata") //Add a new column to the first table
foreach (DataRow dr in tbl.Rows["newcolumnofdata"]) //Go through each row of this new column
{
tbl1.Rows.Add(tbl2.Rows["sourceofdata"]); //Add data into each row from tbl2's column.
tbl1.Columns["date"] = tbl2.Columns["date"]; //The date field being the same in both sources
}
If anyone can help out wud appreciate it, like I say I just need the one column, I don't need to have the whole of the other datatable. Cheers.