asp.net.ph

DataBinder.Eval Method ( Object, String )

System.Web.UI Namespace   DataBinder Class


Evaluates data binding expressions at runtime.

[ VB ]
Overloads Public Shared Function Eval ( _
   ByVal container As Object, _
   ByVal expression As String _
) As Object

[ C# ]
public static object Eval (
   object container,
   string expression
);

[ C++ ]
public: static Object* Eval (
   Object* container,
   String* expression
);

[ JScript ]
public static function Eval (
   container : Object,
   expression : String
) : Object;

Parameters

container
The object reference against which the expression is evaluated. This must be a valild object identifier in the page's specified language.
expression
The navigation path from the container to the property value to be placed in the bound control property. This must be a string type of property or field names separated by dots.

Return Value

The object that results from the evaluation of the data binding expression.

NOTE:

Starting in .NET Framework 4.5, the Object parameter, which references the object against which the expression is evaluated, is optional and thus may be ommitted.

Remarks

While this method is automatically called when you create data bindings in a RAD designer, you can also use it declaratively if you want to simplify the casting to a text string to be displayed on a browser. To do so, you must place the <%# and %> tags, which are also used in standard ASP.NET data binding, around the data binding expression.

This method is particularly useful when data binding against controls that are in a templated list.

CAUTION: Since this method is called at runtime, it can cause performance to noticeably slow compared to standard ASP.NET databinding syntax. Use this method judiciously.

For any of the list Web controls, such as DataList, DataGrid, or Repeater, the container parameter should be Container.DataItem. If you are binding against the page, the container parameter should be Page.

Example

The following example demonstrates how you can use the Eval method to declaratively bind to a Price field. This example uses container syntax that assumes you are using one of the list Web controls.

<%# DataBinder.Eval ( Container.DataItem, "Price" ) %>
See Also

DataBinder Members   DataBinder.Eval Overload List Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph