Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Eval Method

DataBinder.Eval Method

Uses reflection to parse and evaluate a data-binding expression against an object at run time. This method allows RAD designers, such as Visual Studio .NET, to easily generate and parse data-binding syntax. This method can also be used declaratively on a Web Forms page to simplify casting from one type to another.

Overload List

Evaluates data-binding expressions at runtime.

[Visual Basic] Overloads Public Shared Function Eval(Object, String) As Object
[C#] public static object Eval(object, string);
[C++] public: static Object* Eval(Object*, String*);
[JScript] public static function Eval(Object, String) : Object;

Evaluates data-binding expressions at runtime and formats the result as text to be displayed in the requesting browser.

[Visual Basic] Overloads Public Shared Function Eval(Object, String, String) As String
[C#] public static string Eval(object, string, string);
[C++] public: static String* Eval(Object*, String*, String*);
[JScript] public static function Eval(Object, String, String) : String;


[Visual Basic, C#, JScript] The following example demonstrates how to use the Eval method declaratively to bind to a Price field. This example uses container syntax that assumes you are using one of the list Web server controls. The format parameter formats the number as a locale-specific currency string that will be displayed by the requesting browser.

[Visual Basic, C#, JScript] Note   This example shows how to use one of the overloaded versions of Eval. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
<%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}") %>

<%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}") %>

<%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}") %>

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

DataBinder Class | DataBinder Members | System.Web.UI Namespace

© 2015 Microsoft