Text='<%# Eval("LocationType")%> vs Text='<%#Bind("LocationType") %>'>

689 views Asked by At

What is the difference in:

Text='<%# Eval("LocationType")%> vs  Text='<%#Bind("LocationType") %>'>

Thanks

1

There are 1 answers

2
Deepak Kumar On BEST ANSWER

The Bind keyword works like Eval to display data and can retrieve the value you've entered when updating or inserting a record. In addition, Bind is very useful in TemplateFields used in the GridView and DetailsView. Bind stores the value of the bound control property into a collection of values that the FormView control automatically retrieves and uses to compose the parameter list of the insert or edit command. The argument passed to Bind must match the name of a field in the data container. For example, the textbox in the code snippet provides the value for the notes field.

' />

The .NET Framwork 2.0 introduces Eval(). Eval() is a shortcut for Container.DataItem(). Since Eval() uses Reflection, it causes overhead. From a optimization standpoint, it is better to use Container.DataItem().