HTMLEncode in Code-Behind GridView BoundField
Posted on 2008-10-02
I have successfully created a GridView in my code and can add a BoundColumn too. However, when the column is drawn on the page, the HTML tags are displayed.
Dim dg As New GridView
dg.AutoGenerateColumns = False
dg.ShowHeader = False
dg.CssClass = "SubReqBox_on"
Dim dgc As BoundField = New BoundField()
dgc.DataField = "CRSubRequirement"
dgc.HtmlEncode = True
dgc.HtmlEncodeFormatString = True
dgc.InsertVisible = True
dg.DataSource = ds
The text in my DB that corresponds to CRSubRequirement would be something like:
<div>words words words</div>
And of course, I don't want those Div tags showing in my grid.