Edwin Wang's Blog

If there were no clouds, we should not enjoy the sun~~~ edwin-wang.com

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
dotNet 2.0后,M$推荐使用GridView取代DataGrid(Comparing the GridView and DataGrid Web Server Controls)。在做Testlink测试Case的Chart,然后想在表中插入HTML format的时候出现了奇怪的问题。DataGrid一切正常,GridView貌似对直接插入的HTML进行了encode,HTML原始显示了出来。

狂搜一遍,

protected void gvTP_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[1].Text = Server.HtmlDecode(e.Row.Cells[1].Text);
}
}

这下加入的HTML format就不会给encode咯。

posted on 2009-05-13 20:32  laughterwym  阅读(2801)  评论(0编辑  收藏  举报