Number | Base of difference | Bind Function | Eval Function |
1 | Binding | Well when we say about the Bind function , it used for two-way binding (Write and Read). For example when you want to update any database field, here you will be using TextBox and thus by using bind function. | Well when we say about the Eval function, it used to define one-way binding(Read only). For example when we say control like GridView or the FormView. We use this to display read only data by using a label control. We will use this function. |
2 | USed For | Well when we say about the Bind function it can be used to bind data to control inside a DataBound control and also it can update the values back to database. | Well when we say about the Eval function, it can be used to bind data to control inside a DataBound control, but it cannot update the values back to the database. |
3 | Method | Well when we say about the Bind function,it is a new ASP.NET 2.0 databinding keyword. It is not a method of any specific class. | Well when we say about the Eval function, it is protected method define on the template control class, from which the Page class is derived. |
4 | Controls | Well when we say about the Bind function, it applies to control like the GridView, FormsView and Detailsview. | Well when we say about the Eval function, it applies to control like the GridView, DataList, Repeater, ListView, FormsView and DetailsView. |
5 | Control ID
| It does not need the ID of a particular control. For example :-
<table>
<tr>
<td><%#Eval("productname")%> </td>
</tr>
</table> | It always needs the ID of a particular control. For Example:-
<table>
<tr>
<td><%#Bind("productname")%> </td>
</tr>
</table>
is WRONG.
We have to take some UI control like Label and specify the Binding in the Text property.
e.g.,
<ItemTemplate>
<asp:Label ID="lblDOB" runat="server" Text='<%# Bind("DOB") %>'></asp:Label>
</ItemTemplate>
|