Adding List Array item In A Data Table Using Loop Results Error .. .

Posted by Syed Raza on Stack Overflow See other posts from Stack Overflow or by Syed Raza
Published on 2011-07-01T07:26:16Z Indexed on 2011/07/01 8:22 UTC
Read the original article Hit count: 266

Filed under:

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);
    }
}

© Stack Overflow or respective owner

Related posts about c#