DataBinder Class
Collapse the table of content
Expand the table of content

DataBinder Class


Provides support for rapid application development (RAD) designers to generate and parse data-binding expression syntax. This class cannot be inherited.

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


public sealed class DataBinder


This API supports the product infrastructure and is not intended to be used directly from your code. Initializes a new instance of the DataBinder class.


Gets or sets a value that indicates whether data caching is enabled at run time.


Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticEval(Object, String)

Evaluates data-binding expressions at run time.

System_CAPS_pubmethodSystem_CAPS_staticEval(Object, String, String)

Evaluates data-binding expressions at run time and formats the result as a string.


Retrieves an object's declared data item.

System_CAPS_pubmethodSystem_CAPS_staticGetDataItem(Object, Boolean)

Retrieves an object's declared data item, indicating success or failure.


Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticGetIndexedPropertyValue(Object, String)

Retrieves the value of a property of the specified container and navigation path.

System_CAPS_pubmethodSystem_CAPS_staticGetIndexedPropertyValue(Object, String, String)

Retrieves the value of the specified property for the specified container, and then formats the results.

System_CAPS_pubmethodSystem_CAPS_staticGetPropertyValue(Object, String)

Retrieves the value of the specified property of the specified object.

System_CAPS_pubmethodSystem_CAPS_staticGetPropertyValue(Object, String, String)

Retrieves the value of the specified property of the specified object, and then formats the results.


Gets the Type of the current instance.(Inherited from Object.)


Determines whether the specified data type can be bound.


Returns a string that represents the current object.(Inherited from Object.)

You can use the overloaded static Eval method of this class in data-binding syntax in an ASP.NET Web page. This provides an easier syntax to work with than standard data binding. However, because DataBinder.Eval provides automatic type conversion, it can result in slower performance.

For more information about ASP.NET data binding, expressions, and syntax, see Binding to Databases and Data-Binding Expressions Overview.

Starting in .NET Framework 4.5, you can use model binding to simplify some of the tasks that you had to perform through data-binding in earlier versions. For a tutorial series on using model binding with Web Forms, see Model Binding and Web Forms.

The following example uses the static GetPropertyValue method to populate the fields of a Repeater control using an ArrayList of Product objects. The Eval method could be applied with the same syntax, but it would not perform as quickly.

This example uses a custom Product class which exposes a string Model property and a numeric UnitPrice property.

The following code is the custom Product class. This code should be included in a separate class file in the App_Code directory, such as Product.cs or Product.vb.

namespace ASPSample

    public class Product
        string _Model;
        double _UnitPrice;

        public Product(string Model, double UnitPrice)
            _Model = Model;
            _UnitPrice = UnitPrice;

        // The product Model.
        public string Model
            get {return _Model;}
            set {_Model = value;}

        // The price of the each product.
        public double UnitPrice
            get {return _UnitPrice;}
            set {_UnitPrice = value;}

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
© 2015 Microsoft