Strong Typed DataTables and Calculations.
I am in the process of converting everything over from inline SQL to a DAL using strong typed datatables. The problem I am running into is needing to add custom columns and values to these datatables on the fly before I bind them to a grid.
An example would be wanting to add a 'color' field to a datable that I use to change the color of text in a specific field in a datagrid. Currently I do this by adding a 'color' column to my datatable and when I pull data into the datatable from the sql server I use a foreach loop and run my calculations for each row and then add the value into that column.
e.g.
dt.Columns.Add(new DataColumn("itemColor", typeof(string)));
foreach (DataRow dirRow in ds.Tables[0].Rows)
{
if (dirRow["STATUS_ID"].ToString() == "1")
{
dr[8] = "red";
}
else if (dirRow["STATUS_ID"].ToString() == "2")
{
dr[8] = "blue";
}
}
Is there a way I can replicate this behavior with strong typed dataTables?
Thanks in advance.