Back to Devexpress

HtmlContentControl.DataContext Property

windowsforms-devexpress-dot-xtraeditors-dot-htmlcontentcontrol-f1d46ca2.md

latest2.3 KB
Original Source

HtmlContentControl.DataContext Property

Gets or sets the control’s data context (a business object or data source item).

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DefaultValue(null)]
[DXCategory("Data")]
public object DataContext { get; set; }
vb
<DefaultValue(Nothing)>
<DXCategory("Data")>
Public Property DataContext As Object

Property Value

TypeDefaultDescription
Objectnull

The data context.

|

Remarks

The DataContext property allows you to bind the control to a data context (a business object or data source item).

Use the following syntax to display a value of a specific field from the bound data context: ${FieldName}

For example, the following code displays a value of the “UserName” field from the data context.

html
<div class='contactName'>${UserName}</div>

The ‘$’ character at the beginning of the “${UserName}” expression specifies that the text that follows is an interpolated string—an expression that the control needs to evaluate. An interpolated string can contain static text, data binding to multiple fields, and field value formatting (see string interpolation for more information). The following example adds the ‘Welcome’ string before a user name:

html
<h1>$Welcome {UserName}!</h1>

See Also

HtmlContentControl Class

HtmlContentControl Members

DevExpress.XtraEditors Namespace