What is the difference between Eval and Bind methods?

 Posted by Ddd on 1/16/2011 | Category: ASP.NET Interview questions | Views: 11373 | Points: 40
Answer:

Both Eval and Bind apply to the templated controls like the GridView, FormsView.

But there are certain differences

1)Eval method:
a)It supports only one way binding. It means that we can only read data from the
column using Eval method.
b)It does not need the ID of a particular control
example:
<table>
<tr>
<td><%#Eval("productname")%> </td>
</tr>
</table>
is OK.
c)It applies to controls like the GridView, DataList, Repeater, ListView, FormsView, DetailsView.

1)Bind method:
a)It supports two way binding. It means that we can read data and modify data using the Bind method.
b)It always needs the ID of a particular control
example:
<table>
<tr>
<td><%#Bind("productname")%> </td>
</tr>
</table>
is WRONG
we have to take some UI control like Label aand specify the Binding in the
Text property.
c)It applies to controls like the GridView, FormsView, DetailsView.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response