我需要将此 html 页面重写为字符串:
<h1>Report @ViewData["reviewId"]</h1>
<table width="1000">
@foreach (var group in Model.GroupBy(item => item.Parent_Group_Name))
{
<tr bgcolor="gray">
<td><b>@group.Key</b></td>
</tr>
foreach (var line in group)
{
<tr>
<td><b>@line.Child_Group_Name </b></td>
</tr>
<tr>
<td width="100%"><b>Question:</b> @String.Format("{0}. {1}",line.Question_Order,line.Question_Label)</td>
</tr>
<tr>
<td width="100%"><b>Answer:</b> @line.Question_Answer</td>
</tr>
<tr>
<td valign=right>
<table width="100%" >
<thead bgcolor="BDBDBD">Comments</thead>
@foreach (var comment in line.Comments)
{
<tr>
<td width="100%"><font size="3" color=302F2F>@comment.Comment_Text</font></td>
</tr>
<tr>
<td width="100%"><font size="2" color=302F2F>by @comment.Comment_User...[@comment.Comment_Date.ToShortDateString()] </font></td>
</tr>
}
</table><hr />
</td>
</tr>
}
}
</table>
我在想只是使用字符串生成器来包装所有这些 html,有没有更有效或更优雅的方法来做到这一点?