Supporting Simplified Databinding
The databinding expressions used in the previous two sections might seem a little odd. For example, we used the following databinding expression to refer to the Title
property:
<%# Container.Title %>
When you use a databinding expression with one of the standard ASP.NET controls, such as the GridView
control, you typically use a databinding expression that looks like this:
<%# Eval("Title") %>
Why the difference? The standard ASP.NET controls support a simplified databinding syntax. If you want to support this simplified syntax in your custom controls, you must implement the IDataItemContainer
interface.
The IDataItemContainer
includes the following three properties, which you are required to implement:
•
Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.