我正在创建Dynamic HTML Table
填充了使用数据的DataTable
标记C#
。我正在使用StringBuilder
对象 Built-up HTML 标记。编译时出现错误“无法将字符串转换为字符串生成器”
代码:
DataTable dt=new DataTable();
dt=GetData();
StringBuilder strDeviceList=new StringBuilder();
strDeviceList = "<table style='width:100%;text-align:center;'>" +
"<tr>" +
"<td> Quote ID</td><td>Device</td><td> Generation</td><td>Condition</td><td>Price</td>" +
"</tr>";
foreach (DataRow row in dt.Rows)
{
strDeviceList.Append("<tr>" +
"<td>" + row["QuoteID"] + "</td><td>" + row["Name"] + "</td><td>" + row["Generation"] + "</td><td>" + row["Condition"] + "</td><td>" + row["Price"] + "</td>" +
"</tr>");
}
strDeviceList.Append("</table>");
任何想法?帮助赞赏!