DataBinder.Eval Method (Object, String, String)
Evaluates data-binding expressions at run time and formats the result as a string.
Assembly: System.Web (in System.Web.dll)
- 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.
- 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.DefaultView..Price in C# or Tables(0).DefaultView.(0).Price in Visual Basic.
The value of expression must evaluate to a public property.
For more information about format strings in the .NET Framework, see Formatting Types.
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 convert the Object resulting from the data-binding expression to a String. To use the method declaratively, 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.
Because this method performs late-bound evaluation, using reflection at run time, it can cause performance to noticeably slow compared to standard ASP.NET data-binding syntax. Use this method judiciously, particularly when string formatting is not required.
The following code 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 contains an expression that formats the number as a locale-specific currency string.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.