【发布时间】:2009-02-11 07:25:36
【问题描述】:
我需要在 GridView 的 RowDataBound 事件中连续删除整个文本(甚至是文本/单元格之间的空白)。 有可能吗?
【问题讨论】:
我需要在 GridView 的 RowDataBound 事件中连续删除整个文本(甚至是文本/单元格之间的空白)。 有可能吗?
【问题讨论】:
C#
关于 RowDataBound 事件
e.Row.Style.Value = "text-decoration:line-through;"
这就是你的 GridView 的渲染方式,它可以工作!
<table>
<tr style="text-decoration:line-through;">
<td>some text</td>
<td>some text</td>
</tr>
<tr style="text-decoration:line-through;">
<td>some text</td>
<td>some text</td>
</tr>
<tr style="text-decoration:line-through;">
<td>some text</td>
<td>some text</td>
</tr>
</table>
【讨论】:
是的,您可以将所有行单元格的内容放入 标记中。例如,
row.Cell[0].Text = "<strike>cell content from row.DataItem</strike>";
但它只会打击单元格中的文本。如果您为该行的表格设置了 cellpadding 和 cellspacing,那么它现在可能看起来不错。
【讨论】:
function oprt_OnRowDataBound(e) {
if (e.dataItem.IsDeleted == true) {
e.row.style.textDecorationLineThrough = true;
};
}
【讨论】:
或者简单地在网格视图的 RowDataBound 事件中写入下面的颜色,它会在网格视图中删除整行
If DataBinder.Eval(e.Row.DataItem, "Notes") <> "" Then
e.Row.ForeColor = Color.Red
e.Row.Font.Strikeout = True
End If
它对我来说很好用
【讨论】: