asp.net.ph

DataBinder.Eval Method ( Object, String, String )

System.Web.UI Namespace   DataBinder Class


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

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

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

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

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

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 of property or field names separated by dots.
format
A .NET Framework format string used to convert the object, which results from the evaluation of the data binding expression, to a string type to be displayed by the requesting browser.

Return Value

The text that results from the evaluation of the data binding expression and conversion to a string type. This will be displayed by the requesting browser.

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, particularly when string formatting is not required.

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 server controls. The format parameter formats the number as a locale-specific currency string that will be displayed by the requesting browser.

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

DataBinder Members   DataBinder.Eval Overload List   Data Binding Expression Syntax 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