databinder.eval

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What's the purpose of this static method? I know the general idea, use
reflection to detect type of source object and extract the property or field,
but won't you always know the type of object you're binding against? When
would this be a mystery? Also, does it make a difference if you have the
first parameter as container.dataitem or just container and then have
dataitem.fieldname for the second parameter? How does it handle these two
situations?

Thanks...

-Ben
 
Hello,

that's probably one corner-stone with the "DataBinder.Eval"-thinking that
you don't need to know the data source row type exactly so changing the data
source type for a reason or another would not require a change in the
databinding expressions as well. So it can help reducing effects of changes,
though it also brings performance cost. (one of those famous design
decisions :-) )

Sometimes it isn't that clear but for example if you bind to a DataReader
the type of the Container.DataItem is System.Data.Common.DBDataRecord, with
DataTable or DataView, it is System.Data.DataRowView. Or with a custom
collection it is of course type of the custom collection item. But if
developer really wants to, it isn't of course mystery (if you know how to
check the type).

If speaking of web forms, Container refers with a DataGrid to a DataGridItem
(DataList->DataListItem, Repeater->RepeaterItem) and DataItem is a property
of it.
 
Back
Top