Вы также можете создать класс, расширяющий GridView, чтобы сделать это
[ToolboxData("<{0}:DecodedGridView runat='server'>")]
public class DecodedGridView : GridView
{
protected override void Render(HtmlTextWriter writer)
{
for (var i = 0; i < Rows.Count; i++)
{
for (var j = 0; j < Rows[i].Cells.Count; j++)
{
if (Rows[i].RowType == DataControlRowType.DataRow
&& !(((DataControlFieldCell)Rows[i].Cells[j]).ContainingField is CommandField))
{
var encoded = Rows[i].Cells[j].Text;
Rows[i].Cells[j].Text = Context.Server.HtmlDecode(encoded);
}
}
}
base.Render(writer);
}
}
Затем вы можете просто изменить GridView так, чтобы вы хотели удалить кодирование HTML.
Просто объявите сборку аналогичным образом:
<%@ Register TagPrefix="MyUI" Namespace="MyProject.UI" Assembly="MyProject" %>
Затем вызовите GridView так:
<MyUI:DecodedGridView ID="MyTableWithHtml" runat="server">
<!-- All the normal GridView stuff -->
</MyUI:DecodedGridView>