# ControlBindingsCollection

Namespace: **Wisej.Web**

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

Represents the collection of data bindings for a [IBindableComponent](/api/wisej.web/data-binding/wisej.web.ibindablecomponent.md).

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

```csharp
public class ControlBindingsCollection : ControlBindingsCollection
```

{% endtab %}

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

```visual-basic
Public Class ControlBindingsCollection
    Inherits ControlBindingsCollection
```

{% endtab %}
{% endtabs %}

## Constructors

### ![](/files/hsR4ok3152WyAf8J2C1u) ControlBindingsCollection(component)

Initializes a new instance of the [ControlBindingsCollection](/api/wisej.web/data-binding/wisej.web.controlbindingscollection.md) class with the specified bindable control.

| Name          | Type                                                                              | Description                                                                                                              |
| ------------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| **component** | [IBindableComponent](/api/wisej.web/data-binding/wisej.web.ibindablecomponent.md) | The [IBindableComponent](/api/wisej.web/data-binding/wisej.web.ibindablecomponent.md) the binding collection belongs to. |

## 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) associated the binding collection.

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

[Control](/api/wisej.web/general/control.md): Returns the [Control](#control) that the collection belongs to.

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

[DataSourceUpdateMode](/api/wisej.web/data-binding/wisej.web.datasourceupdatemode.md): Returns or sets the default [DataSourceUpdateMode](/api/wisej.web/data-binding/wisej.web.datasourceupdatemode.md) for a [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) in the collection.

### ![](/files/hsR4ok3152WyAf8J2C1u) Item(name)

[Binding](/api/wisej.web/data-binding/wisej.web.binding.md): Returns the [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) specified by the control's property name.

### ![](/files/hsR4ok3152WyAf8J2C1u) Item(index)

[Binding](/api/wisej.web/data-binding/wisej.web.binding.md): Returns the [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) at the specified index.

**Throws:**

* [IndexOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.indexoutofrangeexception) The collection doesn't contain an item at the specified index.

## Methods

### ![](/files/hsR4ok3152WyAf8J2C1u) Add(binding)

Adds the specified [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) to the collection.

| Parameter   | Type                                                        | Description                                                             |
| ----------- | ----------------------------------------------------------- | ----------------------------------------------------------------------- |
| **binding** | [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) | The [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) to add. |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception) The *binding* is null.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception) The control property is already data-bound.
* [ArgumentException](https://docs.microsoft.com/dotnet/api/system.argumentexception) The [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) does not specify a valid column.

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

Creates a [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) using the specified control property name, data source, and data member, and adds it to the collection.

| Parameter        | 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.                                                                  |

**Returns:** [Binding](/api/wisej.web/data-binding/wisej.web.binding.md). The newly created [Binding](/api/wisej.web/data-binding/wisej.web.binding.md).

**Throws:**

* [Exception](https://docs.microsoft.com/dotnet/api/system.exception) The *propertyName* is already data-bound.
* [Exception](https://docs.microsoft.com/dotnet/api/system.exception) The *dataMember* doesn't specify a valid member of the *dataSource* .

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

Creates a binding with the specified control property name, data source, data member, and information about whether formatting is enabled, and adds the binding to the collection.

| Parameter             | 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                                            |

**Returns:** [Binding](/api/wisej.web/data-binding/wisej.web.binding.md). The newly created [Binding](/api/wisej.web/data-binding/wisej.web.binding.md).

**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) If formatting is disabled and the *propertyName* is neither a valid property of a control nor an empty string ("").

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

Creates a binding with the specified control property name, data source, data member, and information about whether formatting is enabled, and adds the binding to the collection.

| Parameter             | 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                                            |
| **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.          |

**Returns:** [Binding](/api/wisej.web/data-binding/wisej.web.binding.md). The newly created [Binding](/api/wisej.web/data-binding/wisej.web.binding.md).

**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) If formatting is disabled and the *propertyName* is neither a valid property of a control nor an empty string ("").

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

Creates a binding with the specified control property name, data source, data member, and information about whether formatting is enabled, and adds the binding to the collection.

| Parameter             | 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                                                                                                                                                      |
| **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.                                                                                                                    |

**Returns:** [Binding](/api/wisej.web/data-binding/wisej.web.binding.md). The newly created [Binding](/api/wisej.web/data-binding/wisej.web.binding.md).

**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) If formatting is disabled and the *propertyName* is neither a valid property of a control nor an empty string ("").

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

Creates a binding that binds the specified control property to the specified data member of the specified data source, optionally enabling formatting, propagating values to the data source based on the specified update setting, and adding the binding to the collection.

| Parameter             | 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.                                                     |
| **updateMode**        | [DataSourceUpdateMode](/api/wisej.web/data-binding/wisej.web.datasourceupdatemode.md) | One of the [DataSourceUpdateMode](/api/wisej.web/data-binding/wisej.web.datasourceupdatemode.md) values. |

**Returns:** [Binding](/api/wisej.web/data-binding/wisej.web.binding.md). The newly created [Binding](/api/wisej.web/data-binding/wisej.web.binding.md).

**Throws:**

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

### ![](/files/hsR4ok3152WyAf8J2C1u) Add(propertyName, dataSource, dataMember, formattingEnabled, updateMode, nullValue)

Creates a binding that binds the specified control property to the specified data member of the specified data source, optionally enabling formatting, propagating values to the data source based on the specified update setting, setting the property to the specified value when [DBNull](https://docs.microsoft.com/dotnet/api/system.dbnull) is returned from the data source, and adding the binding to the collection.

| Parameter             | 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.                                                                                                                                                     |
| **updateMode**        | [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). |

**Returns:** [Binding](/api/wisej.web/data-binding/wisej.web.binding.md). The newly created [Binding](/api/wisej.web/data-binding/wisej.web.binding.md)

**Throws:**

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

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

Creates a binding that binds the specified control property to the specified data member of the specified data source, optionally enabling formatting with the specified format string, propagating values to the data source based on the specified update setting, setting the property to the specified value when [DBNull](https://docs.microsoft.com/dotnet/api/system.dbnull) is returned from the data source, and adding the binding to the collection.

| Parameter             | 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.                                                                                                                                                     |
| **updateMode**        | [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.                                                                                                                    |

**Returns:** [Binding](/api/wisej.web/data-binding/wisej.web.binding.md). The newly created [Binding](/api/wisej.web/data-binding/wisej.web.binding.md)

**Throws:**

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

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

Creates a binding that binds the specified control property to the specified data member of the specified data source, optionally enabling formatting with the specified format string, propagating values to the data source based on the specified update setting, setting the property to the specified value when [DBNull](https://docs.microsoft.com/dotnet/api/system.dbnull) is returned from the data source, setting the specified format provider, and adding the binding to the collection.

| Parameter             | 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.                                                                                                                                                     |
| **updateMode**        | [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.                                                            |

**Returns:** [Binding](/api/wisej.web/data-binding/wisej.web.binding.md). The newly created [Binding](/api/wisej.web/data-binding/wisej.web.binding.md).

**Throws:**

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

### ![](/files/lzopMboA31bVq8UIcbT3) AddCore(binding)

Adds a [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) to the collection.

| Parameter   | Type                                                                          | Description                                                                               |
| ----------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| **binding** | [Binding](https://docs.microsoft.com/dotnet/api/system.windows.forms.binding) | The [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) to add to the collection. |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception) The *binding* argument was null.

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

Removes all bindings in the collection.

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

Fires the [CollectionChanged](/api/wisej.web/data-binding/wisej.web.bindingscollection.md#collectionchanged) event.

| Parameter | Type                                                                                                               | Description                                                                                                                                        |
| --------- | ------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| **e**     | [CollectionChangeEventArgs](https://docs.microsoft.com/dotnet/api/system.componentmodel.collectionchangeeventargs) | A [CollectionChangeEventArgs](https://docs.microsoft.com/dotnet/api/system.componentmodel.collectionchangeeventargs) that contains the event data. |

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

Fires the [CollectionChanging](/api/wisej.web/data-binding/wisej.web.bindingscollection.md#collectionchanging) event.

| Parameter | Type                                                                                                               | Description                                                                                                                                    |
| --------- | ------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| **e**     | [CollectionChangeEventArgs](https://docs.microsoft.com/dotnet/api/system.componentmodel.collectionchangeeventargs) | A [CollectionChangeEventArgs](https://docs.microsoft.com/dotnet/api/system.componentmodel.collectionchangeeventargs) that contains event data. |

### ![](/files/hsR4ok3152WyAf8J2C1u) Remove(binding)

Removes the specified [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) from the collection.

| Parameter   | Type                                                        | Description                                                                |
| ----------- | ----------------------------------------------------------- | -------------------------------------------------------------------------- |
| **binding** | [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) | The [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) to remove. |

**Throws:**

* [NullReferenceException](https://docs.microsoft.com/dotnet/api/system.nullreferenceexception) The *binding* is null.

### ![](/files/hsR4ok3152WyAf8J2C1u) RemoveAt(index)

Removes the [Binding](/api/wisej.web/data-binding/wisej.web.binding.md) at the specified index.

| Parameter | Type                                                        | Description                                 |
| --------- | ----------------------------------------------------------- | ------------------------------------------- |
| **index** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The zero-based index of the item to remove. |

**Throws:**

* [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception) The *index* value is less than 0, or it is greater than the number of bindings in the collection.

## Events

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

[CollectionChangeEventHandler](https://docs.microsoft.com/dotnet/api/system.componentmodel.collectionchangeeventhandler) Fired when the collection has changed.

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

[CollectionChangeEventHandler](https://docs.microsoft.com/dotnet/api/system.componentmodel.collectionchangeeventhandler) Fired when the collection is about to change.


---

# 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.controlbindingscollection.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.
