日期:2014-05-18 浏览次数:20773 次
foreach (DataRow row in dt.Rows) { string username = row["name"].ToString(); string daynum = row["total_day"].ToString(); string avgtime = row["total_minute"].ToString(); Decimal hours = Convert.ToDecimal(avgtime) / 60; int minuteday = Convert.ToInt32(Convert.ToDecimal(avgtime) / Convert.ToDecimal(daynum)); ret += "<p username=\"" + username + "\" total_hour=\"" + hours + "\" day_minute=\"" + minuteday + "\"/>"; }
------解决方案--------------------
用了foreach,里面怎么还用下标呢,当然是一行了啊。
DataTable dt = UserDA.GetTime(uid, btime, etime);
foreach (DataRow row in dt.Rows)
{
string username = row["name"].ToString();
string daynum = row["total_day"].ToString();
string avgtime = row["total_minute"].ToString();
...
}