运到盛时须警醒,境当逆处要从容

我的微博http://weibo.com/chrisfuz
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Difference between Eval() and Bind()

Posted on 2011-12-17 10:35  Chris_Fu  阅读(202)  评论(0)    收藏  举报

Eval() method provides only for displaying data from a datasource in a contral

Bind() method provides for two-way binding which means that it cannot be used to display as well update date from a datasource.

 

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.

 

Reference to the web site http://www.cnblogs.com/DareOnly/archive/2008/08/28/1278168.html