【发布时间】:2011-06-08 14:48:06
【问题描述】:
我正在使用 GridView 控件,它生成以下 HTML:
<table>
<tr><td>...</td><td>...</td></tr>
<tr><td>...</td><td>...</td></tr>
...
</table>
我想把最后一行的 HTML 改成这样:
<table>
<tr><td>...</td><td>...</td></tr>
<tr><td>...</td><td>...</td></tr>
...
<tr><td colspan="2"><span>...</span><span>...</span></td></tr>
</table>
我可以设置第一个单元格的 colspan 值,但不知道如何将这两个单元格分组到一个 TD 元素中。 我可以使用 GridView 控件来做到这一点,还是必须使用 Repeater?
任何帮助将不胜感激。
编辑
我正在使用以下代码来解决问题:
// get cell values
string firstValue = lastRow.Cells[0].Text;
string secondValue = lastRow.Cells[1].Text;
// remove the second cell
lastRow.Cells.RemoveAt(1);
// set column span
lastRow.Cells[0].ColumnSpan = 2;
// set text inside TD element
lastRow.Cells[0].Text = "<span>" + totalText + @"</span><span>" +
totalConsumptionText + @"</span>";
【问题讨论】: