以下输出:
由以下代码提供:
<table class="table container">
<tr>
<th class="col-md-1 text-center">
@Html.DisplayNameFor(Function(model) model.SurveyResults.FirstOrDefault().QuestionNum)
</th>
<th class="col-md-2 text-center">
@Html.DisplayNameFor(Function(model) model.SurveyResults.FirstOrDefault().QuestionText)
</th>
.
.
.
<th class="col-md-2">
@Html.DisplayNameFor(Function(model) model.SurveyResults.FirstOrDefault().Answers)
</th>
</tr>
@For Each item In Model.SurveyResults
@<tr>
<td class="col-md-1 text-center">
@Html.DisplayFor(Function(modelItem) item.QuestionNum)
</td>
<td class="col-md-2">
@Html.DisplayFor(Function(modelItem) item.QuestionText)
</td>
.
.
.
<td class="col-md-2">
@For Each ans In item.Answers
@ans.AnswerText
@ans.AnswerStats
@<br />
Next
</td>
</tr>
Next
</table>
在 Answers 列中,括号中的字符串是有关答案的统计信息。我希望统计数据显示为 Answers 右侧的另一列。答案最终会有不同的长度,并且统计数据需要显示在垂直排列的右侧。上面的代码将始终在答案文本的末尾显示统计信息,无论何时出现。
我尝试了 SO 和其他论坛的一些想法,但无法弄清楚如何在每个
最佳答案
您必须在 answers td 元素中添加另一个表格。
我认为这非常相似: Html table tr inside td
关于html - 如何在 HTML <table> 中的 <td> 元素中设置列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32684462/