While working with Infragistics WebDataGrid/WebHierarchicalDataGrid I noticed a strange thing: column’s HtmlEncode property (which should control whether HTML value of grid’s cell is rendered as HTML or shown as is in raw tags) had no effect. Maybe I was doing something wrong, maybe it was the fact that grid columns were generated in server-side code (here is short snippet):
oGridCol = New GridControls.BoundDataField() oGridCol.DataFieldName = sDataColName oGridCol.Header.Text = sCaption oGridCol.Key = sKey if '(some condition) then oGridCol.HtmlEncode = False oGridCol.CssClass = "nowrapHTML" Else oGridCol.HtmlEncode = True oGridCol.CssClass = "nowrapPLAIN" End If
Here if a certain condition is met – column should render HTML (HtmlEncode = False) otherwise it should display HTML tags (HtmlEncode = True). To make cell expand to data width, 2 simple CSS classes were used:
.nowrapHTML {white-space:nowrap} .nowrapPLAIN {white-space:pre}
In following grid first column was being set with HtmlEncode = True, second with HtmlEncode = False, yet both columns were rendered as HTML.