Adding List Array item In A Data Table Using Loop Results Error .. .
- by Syed Raza
I am trying to put the list array(res) item in to the Data Table(_Hdt) using for Loop
I have put the values in "res" list erray using loop...but this loop results in an error: "variable use asd a method ?"
Here _Hdt and dt are data table and res is list array,
for (int r = 0; r < _Hdt.Rows.Count; r++)
{
foreach (DataRow row in dt.Select("DATE='" + _Hdt.Rows[r]["DATE"].ToString().Trim() + "'"))
{
DateTime date = Convert.ToDateTime(_Hdt.Rows[r]["DATE"].ToString().Trim());
string dateformat = String.Format("{0:dddd MMM d}", date);
_Hdt.Rows[r]["DATE"] = dateformat;
_Hdt.Rows[r]["MTU"] = row["MTU"].ToString().Trim();
_Hdt.Rows[r]["POWER"] = (Convert.ToDecimal(row["POWER"].ToString().Trim()) /
1000).ToString();
_Hdt.Rows[r]["COST"] = row["COST"].ToString().Trim();
_Hdt.Rows[r]["VOLTAGE"] = row["VOLTAGE"].ToString().Trim();
_Hdt.Rows[r]["KW"] = res(r);
}
}