# Binding

Namespace: **Wisej.Web**

Assembly: **Wisej.Framework** (4.0.0.0)

Represents the simple binding between the property value of an object and the property value of a [IBindableComponent](/api/wisej.web/data-binding/wisej.web.ibindablecomponent.md).

{% tabs %}
{% tab title="C#" %}

```csharp
public class Binding : Binding, IBinding
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class Binding
    Inherits Binding
    Implements IBinding
```

{% endtab %}
{% endtabs %}

## Constructors

### ![](/files/hsR4ok3152WyAf8J2C1u) Binding(propertyName, dataSource, dataMember)

Initializes a new instance of the [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) class that simple-binds the indicated control property to the specified data member of the data source.

| Name             | Type                                                          | Description                                                                                       |
| ---------------- | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **propertyName** | [String](https://docs.microsoft.com/dotnet/api/system.string) | The name of the control property to bind.                                                         |
| **dataSource**   | [Object](https://docs.microsoft.com/dotnet/api/system.object) | An [Object](https://docs.microsoft.com/dotnet/api/system.object) that represents the data source. |
| **dataMember**   | [String](https://docs.microsoft.com/dotnet/api/system.string) | The property or list to bind to.                                                                  |

**Throws:**

* [Exception](https://docs.microsoft.com/dotnet/api/system.exception) *propertyName* is neither a valid property of a control nor an empty string ("").
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception) The property given by *propertyName* does not exist on the control.

### ![](/files/hsR4ok3152WyAf8J2C1u) Binding(propertyName, dataSource, dataMember, formattingEnabled)

Initializes a new instance of the [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) class that binds the indicated control property to the specified data member of the data source, and optionally enables formatting to be applied.

| Name                  | Type                                                            | Description                                                                                       |
| --------------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **propertyName**      | [String](https://docs.microsoft.com/dotnet/api/system.string)   | The name of the control property to bind.                                                         |
| **dataSource**        | [Object](https://docs.microsoft.com/dotnet/api/system.object)   | An [Object](https://docs.microsoft.com/dotnet/api/system.object) that represents the data source. |
| **dataMember**        | [String](https://docs.microsoft.com/dotnet/api/system.string)   | The property or list to bind to.                                                                  |
| **formattingEnabled** | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) | true to format the displayed data; otherwise, false.                                              |

**Throws:**

* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception) The property given by *propertyName* does not exist on the control; or the property given is a read-only property.
* [Exception](https://docs.microsoft.com/dotnet/api/system.exception) Formatting is disabled and *propertyName* is neither a valid property of a control nor an empty string ("").

### ![](/files/hsR4ok3152WyAf8J2C1u) Binding(propertyName, dataSource, dataMember, formattingEnabled, dataSourceUpdateMode)

Initializes a new instance of the [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) class that binds the specified control property to the specified data member of the specified data source. Optionally enables formatting and propagates values to the data source based on the specified update setting.

| Name                     | Type                                                                                  | Description                                                                                              |
| ------------------------ | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| **propertyName**         | [String](https://docs.microsoft.com/dotnet/api/system.string)                         | The name of the control property to bind.                                                                |
| **dataSource**           | [Object](https://docs.microsoft.com/dotnet/api/system.object)                         | An [Object](https://docs.microsoft.com/dotnet/api/system.object) representing the data source.           |
| **dataMember**           | [String](https://docs.microsoft.com/dotnet/api/system.string)                         | The property or list to bind to.                                                                         |
| **formattingEnabled**    | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean)                       | true to format the displayed data; otherwise, false.                                                     |
| **dataSourceUpdateMode** | [DataSourceUpdateMode](/api/wisej.web/data-binding/wisej.web.datasourceupdatemode.md) | One of the [DataSourceUpdateMode](/api/wisej.web/data-binding/wisej.web.datasourceupdatemode.md) values. |

**Throws:**

* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception) The property given by *propertyName* does not exist on the control; or the data source or data member or control property specified are associated with another binding in the collection.

### ![](/files/hsR4ok3152WyAf8J2C1u) Binding(propertyName, dataSource, dataMember, formattingEnabled, dataSourceUpdateMode, nullValue)

Initializes a new instance of the [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) class that binds the indicated control property to the specified data member of the specified data source. Optionally enables formatting, propagates values to the data source based on the specified update setting, and sets the property to the specified value when a [DBNull](https://docs.microsoft.com/dotnet/api/system.dbnull) is returned from the data source.

| Name                     | Type                                                                                  | Description                                                                                                                                                                                              |
| ------------------------ | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **propertyName**         | [String](https://docs.microsoft.com/dotnet/api/system.string)                         | The name of the control property to bind.                                                                                                                                                                |
| **dataSource**           | [Object](https://docs.microsoft.com/dotnet/api/system.object)                         | An [Object](https://docs.microsoft.com/dotnet/api/system.object) representing the data source.                                                                                                           |
| **dataMember**           | [String](https://docs.microsoft.com/dotnet/api/system.string)                         | The property or list to bind to.                                                                                                                                                                         |
| **formattingEnabled**    | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean)                       | true to format the displayed data; otherwise, false.                                                                                                                                                     |
| **dataSourceUpdateMode** | [DataSourceUpdateMode](/api/wisej.web/data-binding/wisej.web.datasourceupdatemode.md) | One of the [DataSourceUpdateMode](/api/wisej.web/data-binding/wisej.web.datasourceupdatemode.md) values.                                                                                                 |
| **nullValue**            | [Object](https://docs.microsoft.com/dotnet/api/system.object)                         | The [Object](https://docs.microsoft.com/dotnet/api/system.object) to be applied to the bound control property if the data source value is [DBNull](https://docs.microsoft.com/dotnet/api/system.dbnull). |

**Throws:**

* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception) The property given by *propertyName* does not exist on the control; or the data source or data member or control property specified are associated with another binding in the collection.

### ![](/files/hsR4ok3152WyAf8J2C1u) Binding(propertyName, dataSource, dataMember, formattingEnabled, dataSourceUpdateMode, nullValue, formatString)

Initializes a new instance of the [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) class that binds the specified control property to the specified data member of the specified data source. Optionally enables formatting with the specified format string; propagates values to the data source based on the specified update setting; and sets the property to the specified value when a [DBNull](https://docs.microsoft.com/dotnet/api/system.dbnull) is returned from the data source.

| Name                     | Type                                                                                  | Description                                                                                                                                                                                              |
| ------------------------ | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **propertyName**         | [String](https://docs.microsoft.com/dotnet/api/system.string)                         | The name of the control property to bind.                                                                                                                                                                |
| **dataSource**           | [Object](https://docs.microsoft.com/dotnet/api/system.object)                         | An [Object](https://docs.microsoft.com/dotnet/api/system.object) representing the data source.                                                                                                           |
| **dataMember**           | [String](https://docs.microsoft.com/dotnet/api/system.string)                         | The property or list to bind to.                                                                                                                                                                         |
| **formattingEnabled**    | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean)                       | true to format the displayed data; otherwise, false.                                                                                                                                                     |
| **dataSourceUpdateMode** | [DataSourceUpdateMode](/api/wisej.web/data-binding/wisej.web.datasourceupdatemode.md) | One of the [DataSourceUpdateMode](/api/wisej.web/data-binding/wisej.web.datasourceupdatemode.md) values.                                                                                                 |
| **nullValue**            | [Object](https://docs.microsoft.com/dotnet/api/system.object)                         | The [Object](https://docs.microsoft.com/dotnet/api/system.object) to be applied to the bound control property if the data source value is [DBNull](https://docs.microsoft.com/dotnet/api/system.dbnull). |
| **formatString**         | [String](https://docs.microsoft.com/dotnet/api/system.string)                         | One or more format specifier characters that indicate how a value is to be displayed.                                                                                                                    |

**Throws:**

* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception) The property given by *propertyName* does not exist on the control; or the data source or data member or control property specified are associated with another binding in the collection.

### ![](/files/hsR4ok3152WyAf8J2C1u) Binding(propertyName, dataSource, dataMember, formattingEnabled, dataSourceUpdateMode, nullValue, formatString, formatInfo)

Initializes a new instance of the [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) class with the specified control property to the specified data member of the specified data source. Optionally enables formatting with the specified format string; propagates values to the data source based on the specified update setting; enables formatting with the specified format string; sets the property to the specified value when a [DBNull](https://docs.microsoft.com/dotnet/api/system.dbnull) is returned from the data source; and sets the specified format provider.

| Name                     | Type                                                                                  | Description                                                                                                                                                                                              |
| ------------------------ | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **propertyName**         | [String](https://docs.microsoft.com/dotnet/api/system.string)                         | The name of the control property to bind.                                                                                                                                                                |
| **dataSource**           | [Object](https://docs.microsoft.com/dotnet/api/system.object)                         | An [Object](https://docs.microsoft.com/dotnet/api/system.object) representing the data source.                                                                                                           |
| **dataMember**           | [String](https://docs.microsoft.com/dotnet/api/system.string)                         | The property or list to bind to.                                                                                                                                                                         |
| **formattingEnabled**    | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean)                       | true to format the displayed data; otherwise, false.                                                                                                                                                     |
| **dataSourceUpdateMode** | [DataSourceUpdateMode](/api/wisej.web/data-binding/wisej.web.datasourceupdatemode.md) | One of the [DataSourceUpdateMode](/api/wisej.web/data-binding/wisej.web.datasourceupdatemode.md) values.                                                                                                 |
| **nullValue**            | [Object](https://docs.microsoft.com/dotnet/api/system.object)                         | The [Object](https://docs.microsoft.com/dotnet/api/system.object) to be applied to the bound control property if the data source value is [DBNull](https://docs.microsoft.com/dotnet/api/system.dbnull). |
| **formatString**         | [String](https://docs.microsoft.com/dotnet/api/system.string)                         | One or more format specifier characters that indicate how a value is to be displayed.                                                                                                                    |
| **formatInfo**           | [IFormatProvider](https://docs.microsoft.com/dotnet/api/system.iformatprovider)       | An implementation of [IFormatProvider](https://docs.microsoft.com/dotnet/api/system.iformatprovider) to override default formatting behavior.                                                            |

**Throws:**

* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception) The property given by *propertyName* does not exist on the control; or the data source or data member or control property specified are associated with another binding in the collection.

## Properties

### ![](/files/hsR4ok3152WyAf8J2C1u) BindableComponent

[IBindableComponent](/api/wisej.web/data-binding/wisej.web.ibindablecomponent.md): Returns the [IBindableComponent](/api/wisej.web/data-binding/wisej.web.ibindablecomponent.md) this [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) is associated with. (Default: `null`)

### ![](/files/hsR4ok3152WyAf8J2C1u) BindingMemberInfo

[BindingMemberInfo](/api/wisej.web/data-binding/wisej.web.bindingmemberinfo.md): Return the binding information based on the dataMember parameter in the [#ctor](##ctor) constructor.

### ![](/files/hsR4ok3152WyAf8J2C1u) Control

[Control](/api/wisej.web/general/control.md): Returns the control that the binding belongs to. (Default: `null`)

### ![](/files/hsR4ok3152WyAf8J2C1u) ControlUpdateMode

[ControlUpdateMode](/api/wisej.web/data-binding/wisej.web.controlupdatemode.md): Returns or sets when changes to the data source are propagated to the bound control property. (Default: `OnPropertyChanged`)

### ![](/files/hsR4ok3152WyAf8J2C1u) DataSource

[Object](https://docs.microsoft.com/dotnet/api/system.object): Returns the data source for this binding.

### ![](/files/hsR4ok3152WyAf8J2C1u) DataSourceNullValue

[Object](https://docs.microsoft.com/dotnet/api/system.object): Returns or sets the value to be stored in the data source if the control value is null or empty.

### ![](/files/hsR4ok3152WyAf8J2C1u) DataSourceUpdateMode

[DataSourceUpdateMode](/api/wisej.web/data-binding/wisej.web.datasourceupdatemode.md): Returns or sets a value that indicates when changes to the bound control property are propagated to the data source. (Default: `OnValidation`)

### ![](/files/lzopMboA31bVq8UIcbT3) Events

[EventHandlerList](https://docs.microsoft.com/dotnet/api/system.componentmodel.eventhandlerlist): Returns the list of event handlers that are attached to this [Component](https://docs.microsoft.com/dotnet/api/system.componentmodel.component).

### ![](/files/hsR4ok3152WyAf8J2C1u) FormatInfo

[IFormatProvider](https://docs.microsoft.com/dotnet/api/system.iformatprovider): Returns or sets the [IFormatProvider](https://docs.microsoft.com/dotnet/api/system.iformatprovider) that provides custom formatting behavior. (Default: `null`)

### ![](/files/hsR4ok3152WyAf8J2C1u) FormatString

[String](https://docs.microsoft.com/dotnet/api/system.string): Returns or sets the format specifier characters that indicate how a value is to be displayed.

### ![](/files/hsR4ok3152WyAf8J2C1u) FormattingEnabled

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns or sets a value indicating whether type conversion and formatting is applied to the control property data. (Default: `False`)

### ![](/files/hsR4ok3152WyAf8J2C1u) IsBinding

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns whether the binding is active.

### ![](/files/hsR4ok3152WyAf8J2C1u) NullValue

[Object](https://docs.microsoft.com/dotnet/api/system.object): Returns or sets the [Object](https://docs.microsoft.com/dotnet/api/system.object) to be set as the control property when the data source contains a [DBNull](https://docs.microsoft.com/dotnet/api/system.dbnull) value.

### ![](/files/hsR4ok3152WyAf8J2C1u) PropertyName

[String](https://docs.microsoft.com/dotnet/api/system.string): Returns the name of the control's data-bound property. (Default: `""`)

## Methods

### ![](/files/lzopMboA31bVq8UIcbT3) OnBindingComplete(e)

Fires the [BindingComplete](#bindingcomplete) event.

| Parameter | Type                                                                                          | Description                                                                                                                   |
| --------- | --------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| **e**     | [BindingCompleteEventArgs](/api/wisej.web/data-binding/wisej.web.bindingcompleteeventargs.md) | A [BindingCompleteEventArgs](/api/wisej.web/data-binding/wisej.web.bindingcompleteeventargs.md) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnFormat(e)

Fires the [Format](#format) event.

| Parameter | Type                                                                          | Description                                                                                                   |
| --------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| **e**     | [ConvertEventArgs](/api/wisej.web/data-binding/wisej.web.converteventargs.md) | A [ConvertEventArgs](/api/wisej.web/data-binding/wisej.web.converteventargs.md) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnParse(e)

Fires the [Parse](#parse) event.

| Parameter | Type                                                                          | Description                                                                                                   |
| --------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| **e**     | [ConvertEventArgs](/api/wisej.web/data-binding/wisej.web.converteventargs.md) | A [ConvertEventArgs](/api/wisej.web/data-binding/wisej.web.converteventargs.md) that contains the event data. |

### ![](/files/hsR4ok3152WyAf8J2C1u) ReadValue()

Sets the control property to the value read from the data source.

### ![](/files/hsR4ok3152WyAf8J2C1u) WriteValue()

Reads the current value from the control property and writes it to the data source.

## Events

### ![](/files/hsR4ok3152WyAf8J2C1u) BindingComplete

[BindingCompleteEventHandler](/api/wisej.web/data-binding/wisej.web.bindingcompleteeventhandler.md) Fired when the [FormattingEnabled](#formattingenabled) property true and a binding operation is completed.

### ![](/files/hsR4ok3152WyAf8J2C1u) Format

[ConvertEventHandler](/api/wisej.web/data-binding/wisej.web.converteventhandler.md) Fired when the property of a control is bound to a data value.

### ![](/files/hsR4ok3152WyAf8J2C1u) Parse

[ConvertEventHandler](/api/wisej.web/data-binding/wisej.web.converteventhandler.md) Fired when the value of a data-bound control changes.

## Implements

| Name                                                          | Description                             |
| ------------------------------------------------------------- | --------------------------------------- |
| [IBinding](/api/wisej.web/data-binding/wisej.web.ibinding.md) | Defines a component's binding instance. |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/api/wisej.web/data-binding/wisej.web.binding.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
