This documentation is archived and is not being maintained.

DataBinding Constructor

Initializes a new instance of the DataBinding class.

Namespace:  System.Web.UI
Assembly:  System.Web (in System.Web.dll)

public DataBinding(
	string propertyName,
	Type propertyType,
	string expression


Type: System.String

The property to bind data to.

Type: System.Type

The .NET Framework type of the property to bind data to.

Type: System.String

The data-binding expression to be evaluated.

The following code example creates a DataBinding object and sets it equal to an existing object in the control's DataBindingCollection collection that has a propertyName parameter with a value of Text. If the collection contains a DataBinding object with a propertyName value of Text, this code returns the value of the object's Expression property. If there is no such object, it returns an empty string ("").

// Create a Text property with accessors that obtain  
// the property value from and set the property value 
// to the Text key in the DataBindingCollection class. 
public string Text
        DataBinding myBinding = DataBindings["Text"];
        if (myBinding != null)
            return myBinding.Expression;
        return String.Empty;

        if ((value == null) || (value.Length == 0))

            DataBinding binding = DataBindings["Text"];

            if (binding == null)
                binding = new DataBinding("Text", typeof(string), value);
                binding.Expression = value;
            // Call the DataBinding constructor, then add 
            // the initialized DataBinding object to the  
            // DataBindingCollection for this custom designer.
            DataBinding binding1 = (DataBinding)DataBindings.SyncRoot;

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0