I have seen bind and eval used interchangeably especially in ASP.NET GridViews. What is the difference?
views:
1855answers:
3Bind() is used to two-way databinding. So when used with the proper type of datasource, it will pull the altered values out of the GridView or other control and save them back to the database.
Eval() is a one-way, "read only" way to bind the values.
So I guess it is safe to assume that if I am going to update a database field, I should use Bind, but If I just want to read the field, I can use Eval. The main reason I ask is because I have a gridview with a templated field which has the text "Active" or "Canceled" and depending on the text, I color it differently (Green for Active, Red for Canceled). I do this by using the OnRowDatabound event. I set the color style of the label control. I guess because I am not changing the value and sending it back to the database, I can use Eval. If I am wrong on this, please correct me?
Thanks for the help, X