Using in "Eval" in databound controls

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
 
E

Eliyahu Goldin

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

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top