Wednesday, April 15, 2009

The difference between Eval and Bind data binding functions in ASP.NET

When binding in ASP.NET within FormView, GridView or DetailsView, one could use data-binding expressions with this tag <%# %>. There are two functions, which are Eval and Bind, used frequently. For instance, suppose you a data source has the field named "ProductName", you could bind it as follows:

<%# Eval('ProductName')%> OR <%# Bind('ProductName')%>

So what is the difference between the two functions?
The difference is, according to MSDN, the Eval function is used to define one-way (read-only) binding. The Bind function is used for two-way (updatable) binding.

About Cullen

My photo
Christian, Father, Software Developer/Architect who enjoys technology and using it to make people's lives easier!

Followers