Databases Reference
In-Depth Information
ForeignKey
The
ForeignKey.ascx
is used for foreign key columns in Read-only mode. It contains a
HyperLink
control that displays the field value of the “display” column of the parent table.
You can specify the display column explicitly by applying the
DisplayColumnAttribute
to
the parent entity class, or it can be selected automatically based on the Dynamic Data
heuristics. Users can click the link generated by the control to navigate to the
List.aspx
page of the parent table.
ForeignKey_Edit
The
ForeignKey_Edit.ascx
field template is used for foreign key columns in Edit and
Insert modes. It contains a
DropDownList
control that displays all rows from the parent
table. The display column of the parent table determines the
Text
of each
ListItem
, and
its primary key columns determine its
Value
.
Integer_Edit
The
Integer_Edit.ascx
field template is used for
Byte
,
Int16
,
Int32
, and
Int64
columns in
Edit and Insert modes. It contains a
TextBox
control, accompanied by a
CompareValidator
,
which is used to ensure that values entered in the
TextBox
are valid numbers. It also
contains a
RequiredFieldValidator
, used to enforce values for columns marked with the
RequiredAttribute;
a
RangeValidator
, used to enforce range of values for columns
marked with the
RangeAttribute
; a
RegularExpressionValidator
, used to enforce regular
expression patterns for columns marked with the
RegularExpressionAttribute
; and a
DynamicValidator
, used to enforce all other validation attributes applied to the column.
ManyToMany
The
ManyToMany.ascx
field template is used for children columns in a many-to-many rela-
tionship, such as the Employees column of the Territory entity in the Northwind sample
database. This template contains a
Repeater
control that generates a
DynamicHyperLink
for
every child entity. On the actual page, this looks like a list of hyperlinks that the user can
click to navigate to the
Details.aspx
page of a particular child entity.
NOTE
Many-to-many relationships are natively supported in Entity Framework but not in LINQ
to SQL. Therefore, only the Entity Framework flavors of the Dynamic Data project
templates in Visual Studio include the
ManyToMany
field template. Unlike other field
templates, which work equally well with both data access frameworks, the
ManyToMany
field template uses Entity Framework APIs directly.