Assembly: System.Web (in System.Web.dll)
Thetype exposes the following members.
|ExtractValues||When implemented by a class, retrieves a set of name/value pairs for values bound using two-way ASP.NET data-binding syntax within the templated content.|
|InstantiateIn||When implemented by a class, defines the Control object that child controls and templates belong to. These child controls are in turn defined within an inline template. (Inherited from ITemplate.)|
The interface provides a way for ASP.NET data-bound controls, such as DetailsView, GridView, and FormView, to bind to data supplied by an ASP.NET data source control, such as ObjectDataSource or SqlDataSource, when the data-bound control includes templated content.
Page developers do not implement the interface. Developers creating custom data-bound controls might manipulate objects in implementations of the PerformDataBinding and ExtractRowValues methods, but do not implement their own objects.
Data-bound controls such as 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 instance.
The data binding can be one-way or two-way. (These binding directions are defined by the 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 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 Binding to Databases and Data-Binding Expressions Overview.
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 data-bound control is bound to data using the DataSourceID property of the data source control, and the templated content is defined in an ItemTemplate, EditItemTemplate or InsertItemTemplate property.
The data-bound control is bound to data using the DataSourceID property of the data source control, and the templated content is defined in an ItemTemplate or EditItemTemplate property. The GridView control does not support an insert operation.
The data-bound control is bound to data using the DataSourceID property, and the templated content is defined in an ItemTemplate, InsertItemTemplate, or EditItemTemplate property, or in a TemplateField object.
ASP.NET implicitly creates an 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 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 BindableAttribute attribute.
The interface defines one method, ExtractValues. 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 ExtractValues method must match parameter names in an associated data source control. Control developers call the ExtractValues method explicitly only within their implementations of ExtractRowValues or some other similar method of a custom data-bound control.
The following code example demonstrates how a FormView control can declaratively define templated content, bind to data provided by a SqlDataSource control, and display and edit existing records. The ASP.NET parser parses the templated content and creates an object at run time that is able to bind values from the SqlDataSource control to the data-binding areas defined in the template by both one-way ASP.NET data-binding syntax (<%# Eval("fieldname") %>) and two-way data-binding syntax (<%# Bind("fieldname") %>).
This control has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.