Freigeben über


DataBinding.Expression-Eigenschaft

Ruft den Datenbindungsausdruck ab, der ausgewertet werden soll, oder legt diesen fest.

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

Syntax

'Declaration
Public Property Expression As String
'Usage
Dim instance As DataBinding
Dim value As String

value = instance.Expression

instance.Expression = value
public string Expression { get; set; }
public:
property String^ Expression {
    String^ get ();
    void set (String^ value);
}
/** @property */
public String get_Expression ()

/** @property */
public void set_Expression (String value)
public function get Expression () : String

public function set Expression (value : String)

Eigenschaftenwert

Der Datenbindungsausdruck, der ausgewertet werden soll.

Beispiel

Im folgenden Codebeispiel wird ein DataBinding-Objekt erstellt, und dieses wird gleichgesetzt mit einem vorhandenen Objekt in der DataBindingCollection-Auflistung des Steuerelements, das über einen propertyName-Parameter mit dem Wert Text verfügt. Wenn die Auflistung ein DataBinding-Objekt mit einem propertyName-Wert von Text enthält, gibt dieser Code den Wert der Expression-Eigenschaft des Objekts zurück. Wenn kein solches Objekt vorhanden ist, wird eine leere Zeichenfolge ("") zurückgegeben.

' 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 Property [Text]() As String
    Get
        Dim myBinding As DataBinding = DataBindings("Text")
        If Not (myBinding Is Nothing) Then
            Return myBinding.Expression
        End If
        Return String.Empty
    End Get
    Set(ByVal value As String)

        If value Is Nothing OrElse value.Length = 0 Then
            DataBindings.Remove("Text")
        Else

            Dim binding As DataBinding = DataBindings("Text")

            If binding Is Nothing Then
                binding = New DataBinding("Text", GetType(String), value)
            Else
                binding.Expression = value
            End If
            ' Call the DataBinding constructor, then add
            ' the initialized DataBinding object to the 
            ' DataBindingCollection for this custom designer.
            Dim binding1 As DataBinding = CType(DataBindings.SyncRoot, DataBinding)
            DataBindings.Add(binding)
            DataBindings.Add(binding1)
        End If
        PropertyChanged("Text")
    End Set
End Property
// 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
{
    get
    {
        DataBinding myBinding = DataBindings["Text"];
        if (myBinding != null)
        {
            return myBinding.Expression;
        }
        return String.Empty;
    }
    set
    {

        if ((value == null) || (value.Length == 0))
        {
            DataBindings.Remove("Text");
        }
        else
        {

            DataBinding binding = DataBindings["Text"];

            if (binding == null)
            {
                binding = new DataBinding("Text", typeof(string), value);
            }
            else
            {
                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;
            DataBindings.Add(binding);
            DataBindings.Add(binding1);
        }
        PropertyChanged("Text");
    }
}
// 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.
/** @property 
 */
public String get_Text()
{
    DataBinding myBinding = get_DataBindings().get_Item("Text");
    if (myBinding != null) {
        return myBinding.get_Expression();
    }
    return("");
} //get_Text

/** @property 
 */
public void set_Text(String value)
{
    if (value == null || value.get_Length() == 0) {
        get_DataBindings().Remove("Text");
    }
    else {
        DataBinding binding = get_DataBindings().get_Item("Text");
        if (binding == null) {
            binding = new DataBinding("Text", String.class.ToType(), value);
        }
        else {
            binding.set_Expression(value);
        }

        // Call the DataBinding constructor, then add
        // the initialized DataBinding object to the 
        // DataBindingCollection for this custom designer.
        DataBinding binding1 = (DataBinding)(get_DataBindings().
            get_SyncRoot());
        get_DataBindings().Add(binding);
        get_DataBindings().Add(binding1);
    }
    OnBindingsCollectionChanged("Text");
} //set_Text

Plattformen

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

DataBinding-Klasse
DataBinding-Member
System.Web.UI-Namespace

Weitere Ressourcen

Syntax für Datenbindungsausdrücke