Thursday, April 23, 2015

How to display text in html format in GridView generated from DataTable

In this artical i will expain How to display text in html format in GridView generated from DataTable.

We will use  GridView_RowDataBound to resolve this issue.










solution to this problem.
 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
               for (int i = 0; i < e.Row.Cells.Count; i++) 
               {
                   string encoded = e.Row.Cells[i].Text;
                   e.Row.Cells[i].Text = Context.Server.HtmlDecode(encoded);
               }
        }
    }

No comments:

Post a Comment