System.Web.UI.WebControls Namespace BoundField Class
Sets or retrieves a value specifying whether field values are HTML-encoded before they are displayed in a BoundField.
Inline |
<asp:boundfield htmlencode [ = true | false ] ... > |
Script |
BoundField.HtmlEncode [ = true | false ] |
This property accepts or returns only a boolean value: true if field values are HTML-encoded before they are displayed in a BoundField; otherwise false. Default value is true.
Use the HtmlEncode property to specify whether field values are HTML-encoded before they are displayed in a BoundField control.
NOTE: HTML-encoding field values helps to prevent cross-site scripting attacks and malicious content from being displayed. This property should be enabled whenever possible.
The following example demonstrates how to use the HtmlEncode in conjunction with the DataFormatString property to display prices in a GridView control.
<asp:boundfield headertext = "Price"
datafield = "Price"
dataformatstring = "{0:c}"
htmlencode=false
itemstyle-horizontalalign = "right" />
Show me
BoundField Members