我尝试使用StringBuilder显示表,但它不起作用。它会导致在sb.Append上声明“对象引用未设置为对象实例”的错误(string.Format(。请帮助。谢谢。
foreach (Item item in list)
{
sb.Append(string.Format(
@"<table >
<tr>
<th rowspan ='6' width='150px'><img runat='server' src='{3}'/>
</th>
<th width='50px'>Title: </th>
<td>{0}</td>
</tr>
<tr>
<th>Price:</th>
<td>{1}</td>
</tr>
<tr>
<th>Available: </th>
<td>{2}</td>
</tr>
</table>", item.ItemAttributes.Publisher,item.ItemAttributes.ListPrice.ToString(), item.ItemAttributes.NumberOfItems, item.SmallImage.URL));
lblItemResponse.Text = sb.ToString();
}