Expression Property
Collapse the table of content
Expand the table of content

DataBinding.Expression Property

Gets or sets the data-binding expression to be evaluated.

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

public string Expression { get; set; }

Property Value

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

Community Additions

© 2015 Microsoft