Using in "Eval" in databound controls

  • Thread starter Thread starter Newish
  • Start date Start date
N

Newish

Hi

Is it really not recommended to us Eval in databound controls as
follows:

<td><asp:TextBox id="BookTitle" Runat="Server"
Text='<%# Eval("BookTitle") %>'
Font-Size="8pt" Width="80px"/></td>

If so what is the alternative.

Thanks

Newish
 
It is fine to use Eval. You do pay for this some performance penalty, but it
might be insignificant. You gain independence of the datasource. Whether it
is a table, or an array or whatever else, Eval takes care of it.

The alternative is to have expressions like
<%# ((DataRowView)Container.DataItem)["BookTitle"] %>

This is good for a datatable, but won't work if you change the datasource to
an array.
 
Back
Top