In the <% #%> tags you have access to
- Everything that is visible in your code class (including protected methods and properties).
- Everything declared on an aspx page using <@import @>.
- Everything that was passed as arguments to the event when the ItemDataBound event was fired (for example, RepeaterItemEventArgs, DataListItemEventArgs, etc.).
The container is actually a wrapper for RepeaterItemEventArgs.Item, DataListItemEventArgs.Item, etc. That way, you can access it in code outside of your ItemDataBound events, like e.Item (usually this is the name of the argument argument parameter).
DataBinder is also available in code using System.Web.UI.DataBinder.
The excellent use of Container.DataItem, on the other hand, is preferable to using Eval. Eval uses reflection, so there is overhead. In VB.NET, it will be something like
<%#DirectCast(Container.DataItem, DataRow)("some_column")%>
Or with#
<%#((DataRow)Container.DataItem)["some_column"].ToString()%>
source share