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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top