Q:

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

I have a method to create a DataTable:
private DataTable GetCssPropertiesDataTable()
{
    DataTable dataTable = new DataTable();

    DataColumn column;
    DataRow row;

    column = new DataColumn();
    column.DataType = typeof(string);
    column.ColumnName = "Property";
    column.Caption = "Property";
    dataTable.Columns.Add(column);

    column = new DataColumn();
    column.DataType = typeof(double);
    column.ColumnName = "Value";
    column.Caption = "Value";
    dataTable.Columns.Add(column);

    column = new DataColumn();
    column.DataType = typeof(string);
    column.ColumnName = "Unit";
    column.Caption = "Unit";
    dataTable.Columns.Add(column);

    row = dataTable.NewRow();
    row["Property"] = "A";
    row["Value"] = A;
    row["Unit"] = "m<sup>2</sup>";
    dataTable.Rows.Add(row);

    return dataTable;
}

a gridview (aspx):
<asp:GridView ID="cssPropertiesGridView" runat="server" CssClass="gridView"></asp:GridView>

and databinding in code behing (aspx.cs):
cssPropertiesGridView.DataSource = calculator.CssPropertiesDataTable;
cssPropertiesGridView.DataBind();

the result on a generated web page:
m<sup>2</sup>

Is there way how to display m2 ?

A:

You should specify the property HtmlEncode="false" for unit column (in datagrid) like in the following snippet, in order to display html
<Columns>
    <asp:BoundField DataField="Property" />
    <asp:BoundField DataField="Value" />
    <asp:BoundField DataField="Unit" HtmlEncode="False" />
</Columns>

Hope it helps.

