Evaluates data-binding expressions at run time.
Namespace: System.Web.UI
Assembly: System.Web (in System.Web.dll)
public static Object Eval(
Object container,
string expression
)
Parameters :
container
- Type: System..::.Object
- The object reference against which the expression is evaluated. This must be a valid object identifier in the page's specified language.
expression
- Type: System..::.String
- The navigation path from the container object to the public property value to be placed in the bound control property. This must be a string of property or field names separated by periods, such as Tables[0].DefaultView.[0].Product in C# .
The value of the expression parameter must evaluate to a public property.
This method is automatically called when you create data bindings in a rapid application development (RAD) designer such as Visual Studio. You can also use it declaratively to simplify casting to a text string. To do so, you use the <%# %> expression syntax, as used in standard ASP.NET data binding.
This method is particularly useful when binding data to controls that are in a templated list.
For any of the list Web controls, such as GridView, DetailsView, DataList, or Repeater, container should be Container.DataItem. If you are binding against the page, container should be Page.
<%# DataBinder.Eval (Container.DataItem, "Product") %>