Provides a way for ASP.NET data-bound controls, such as System.Web.UI.WebControls.DetailsView and System.Web.UI.WebControls.FormView, to automatically bind to an ASP.NET data source control within templated content sections.
See Also: IBindableTemplate Members
The System.Web.UI.IBindableTemplate interface provides a way for ASP.NET data-bound controls, such as System.Web.UI.WebControls.DetailsView, System.Web.UI.WebControls.GridView, and System.Web.UI.WebControls.FormView, to bind to data supplied by an ASP.NET data source control, such as System.Web.UI.WebControls.ObjectDataSource or System.Web.UI.WebControls.SqlDataSource, when the data-bound control includes templated content.
Page developers do not implement the System.Web.UI.IBindableTemplate interface. Developers creating custom data-bound controls might manipulate System.Web.UI.IBindableTemplate objects in implementations of the System.Web.UI.WebControls.DataBoundControl.PerformDataBinding(IEnumerable) and System.Web.UI.WebControls.GridView.ExtractRowValues(System.Collections.Specialized.IOrderedDictionary, System.Web.UI.WebControls.GridViewRow, bool, bool) methods, but do not implement their own System.Web.UI.IBindableTemplate objects.
Data-bound controls such as System.Web.UI.WebControls.GridView typically are aware of their child control trees, and can therefore bind values to them, extract values from them, and pass these values between the data-bound control and a data source control whenever data binding occurs. However, when a page developer defines templated content for a data-bound control, the child controls within the template are not visible to the parent data-bound control: the parent can render the child content (because controls effectively render themselves), but it cannot extract the values of these child controls to pass to an associated data source control's update, insert, or delete operation. In data-binding scenarios, templated content is opaque to a parent data-bound control. The Bind syntax makes it possible for the data-bound control to extract the values from a control data-bound inside an System.Web.UI.IBindableTemplate instance.
The data binding can be one-way or two-way. (These binding directions are defined by the System.ComponentModel.BindingDirection enumeration.) One-way data binding is any data binding performed in an outbound direction, from data source control to data-bound control; for example, any data-reading scenario involves one-way data binding. For one-way data binding, you can use one-way data binding syntax (<%# Eval("fieldname") %>) inside templated content, and do not need to use two-way ASP.NET data-binding syntax. Two-way data-binding describes data-binding in the inbound direction, from the data-bound control to the data source control. Automatic edit, insert, and delete scenarios using ASP.NET data-bound and data source controls are two-way data-binding scenarios. These scenarios use two-way data-binding expressions (<%# Bind("fieldname") %>). The System.Web.UI.IBindableTemplate interface and the ASP.NET infrastructure support automatic, declarative, two-way data binding between ASP.NET data source controls and templated content. For more information about ASP.NET data-binding expressions and syntax, see Data Binding and Data-Binding Expression Syntax.
Templated content for data-bound controls is most often defined declaratively. The following table describes the processes most commonly used to bind templated data to data-bound controls.
The System.Web.UI.WebControls.DataList and System.Web.UI.WebControls.Repeater controls do not support automatic two-way data-binding scenarios.
ASP.NET implicitly creates an System.Web.UI.IBindableTemplate object when templated content that binds to an ASP.NET data source control within the template is parsed. Specifically, the ASP.NET parser creates an instance of the System.Web.UI.CompiledBindableTemplateBuilder class when it parses templated content that uses ASP.NET data-binding syntax and contains ASP.NET Web server controls that support data binding. These ASP.NET sever controls are marked by the System.ComponentModel.BindableAttribute attribute.
The System.Web.UI.IBindableTemplate interface defines one method, IBindableTemplate.ExtractValues(Control). This method is defined for two-way data binding, so that a data-bound control can automatically extract name/value pairs from templated content and pass the pairs to a data source control at run time. For automatic data binding to succeed, the field names extracted from the templated content by the IBindableTemplate.ExtractValues(Control) method must match parameter names in an associated data source control. Control developers call the IBindableTemplate.ExtractValues(Control) method explicitly only within their implementations of System.Web.UI.WebControls.FormView.ExtractRowValues(System.Collections.Specialized.IOrderedDictionary, bool) or some other similar method of a custom data-bound control.