How to bind a html to a Gridview column?

c#, gridview, webforms

Solution

Try using - `HttpUtility.HtmlDecode("Lane 1 Suite # 2 <br>")`

The markup will be,

<asp:TemplateField HeaderText="Address">
    <ItemTemplate>
        <%# HttpUtility.HtmlDecode(Eval("Address").ToString()) %>
    </ItemTemplate>
</asp:TemplateField> 

Ref : http://msdn.microsoft.com/en-us/library/7c5fyk1k.aspx

Problem

I have searched about this a lot in google. But, i didn't get any clue. Thanks to you all in advance. Question: i have a html source in my datatable column.when it binds with my gridview, i need to show that html output in my gridview column. Is that Possible ? current output: My aspx code: ``` protected void Page_Load(object sender, EventArgs e) { DataTable dtEmployees = new DataTable(); dtEmployees.Columns.Add(new DataColumn("FirstName", typeof(System.String))); dtEmployees.Columns.Add(new DataColumn("LastName", typeof(System.String))); dtEmployees.Columns.Add(new DataColumn("HomePhone", typeof(System.String))); dtEmployees.Columns.Add(new DataColumn("CellPhone", typeof(System.String))); dtEmployees.Columns.Add(new DataColumn("Address", typeof(System.String))); DataRow drEmpDetail = dtEmployees.NewRow(); drEmpDetail["FirstName"] = "Tony"; drEmpDetail["LastName"] = "Greg"; drEmpDetail["HomePhone"] = "000-000-0000"; drEmpDetail["CellPhone"] = "000-000-0000"; drEmpDetail["Address"] = "Lane 1 Suite # 2 &lt;br&gt;"; } ``` Just for example,In the Address column i have given html tag for the "break tag".But in the output it just displays like a string, the result is not as expected. Note: I don't want to use the Template field instead of BoundField.

Original source