Web Forms supports a hierarchical data binding model that allows page developers to declaratively associate one-way data binding expressions between data sources and server control properties. Any server control property can be data bound (the property is specified declaratively as an attribute name on the server control).
Data binding expressions are defined using <%# %> syntax fragments that can be written either on the value side of a property definition or inline, within literal text. For example:
Value Side
<servercontrol propertyname="<%# DataBinding Expression %>" runat=server/>
Inline
This is the value you data bound: <%# DataBinding Expression %>
Data Binding Expression Scope
Data binding expressions are written in the default language of the page (declared using the Page directive) and can evaluate against any public field or property either on the page itself, or on their immediate naming container (by referencing the strongly typed Container instance pushed into the namespace of each binding expression).
Data Binding Expression Evaluation
Data binding expressions are evaluated at run time in response to a developer explicitly invoking the Control.DataBind method on a control in the tree hierarchy. This call causes a recursive tree walk from that control down through the tree, causing the OnDataBind event to be raised on each server control in the hierarchy and data binding expressions on the control to be evaluated accordingly.
Data Binding Example
<html> <script language="C#" runat=server> public void Page_Load(Object sender, EventArgs e) { ArrayList myList = new ArrayList(); myList.Add("DataItem One"); myList.Add("DataItem Two"); myList.Add("DataItem Three"); MyRepeater.DataSource = myList; MyRepeater.DataBind(); } </script> <body> <asp:repeater id="MyRepeater" runat=server> <template name="itemtemplate"> Here is the value in a text box: <input type=text value="<%#Container.DataItem%>" runat=server> </template> </asp:repeater> </body> </html>