Databases Reference
In-Depth Information
LISTING 3.8
Continued
<add name=”NorthwindEntities”
providerName=”System.Data.EntityClient”
connectionString=”
metadata=res://*/Northwind.csdl|
res://*/Northwind.ssdl|
res://*/Northwind.msl;
provider=System.Data.SqlClient;
provider connection string="
data source=.\sqlexpress;
initial catalog=Northwind;
integrated security=True;
multipleactiveresultsets=True"”/>
</connectionStrings>
</configuration>
Several of the built-in Dynamic Data field templates, including the
DateTime
and
DateTime_Edit
templates, rely on data binding to display column value on the page.
<asp:TextBox ID=”textBox” runat=”server” Text='<%# FieldValueEditString %>' />
In addition, the field template controls themselves are data bound, and several properties
of the
FieldTemplateUserControl
base class rely on the data binding mechanics. These
properties can be used safely
only
from the
DataBind
method and will throw an
InvalidOperationException
when used outside of the data binding context, such as
during a post-back:
.
Row
provides access to the entity instance the field template is bound to,
such as an Order object. In Read-only and Edit modes, it is an equivalent
of calling the
Page.GetDataItem
method. In Insert mode, this property returns a
CustomTypeDescriptor
object that provides access to default field values extracted
by the page template from the page request URL (more on this in Chapter 6, “Page
Templates”).
.
FieldValue
returns value of the column property, such as
Order.OrderDate
. It is an
equivalent of calling
DataBinder.Eval(Row, Column.Name)
.
.
FieldValueString
converts the field value to a display string in Read-only mode,
using the formatting options specified in the data model or page markup. It is an
equivalent of calling
FormattingOptions.FormatValue(FieldValue)
.