Search code examples
asp.netgridvieweval

Difference between usage of eval expressions in asp.net


I have been just trying to understand what does eval do. Suppose, I have a gridview - what is the difference if I use

Text='<%# Eval("FieldName") %>' in .aspx

and

DataBinder.Eval(e.Row.DataItem, "FieldName") in aspx.cs

Can anyone explain in simple terms what does each one of these do and in what case should we use them? Or can they be used interchangeably?


Solution

  • Generally, there is no difference between these two methods as the Eval actually calls the DataBinder.Eval method. For more details, please refer to

    DataBinder.Eval vs Eval