Databases Reference
In-Depth Information
Some visual aspects of entity templates, such as display names of the columns and their
order, can be controlled using metadata attributes. However, the overall layout of the
default template is fundamentally a single column of labels on the left and the data entry
controls on the right. When this layout is insufficient, you can create custom entity
templates to fit your requirements.
Grid Columns and Dynamic Fields
So far, only data entry forms have been discussed, where a single record or entity is
displayed at a time. However, Dynamic Data offers great productivity enhancements for
list type pages that display multiple records.
LISTING 1.13
GridView and DynamicField Sample (Markup)
<%@ Page Language=”C#”
MasterPageFile=”~/Site.master” CodeBehind=”SamplePage.aspx.cs”
Inherits=”WebApplication.Samples.Ch01.DynamicField.SamplePage” %>
<asp:Content ContentPlaceHolderID=”main” runat=”server”>
<asp:ValidationSummary runat=”server”/>
<asp:GridView ID=”gridView” runat=”server” DataSourceID=”dataSource”
DataKeyNames=”ProductID” AutoGenerateEditButton=”true”
AllowPaging=”true” AutoGenerateColumns=”false” >
<columns>
<asp:DynamicField DataField=”ProductName” />
<asp:DynamicField DataField=”UnitsInStock” />
</columns>
</asp:GridView>
<asp:EntityDataSource ID=”dataSource” runat=”server”
ConnectionString=”name=NorthwindEntities” EnableUpdate=”true”
DefaultContainerName=”NorthwindEntities” EntitySetName=”Products” />
</asp:Content>
DynamicField is a data control field that can be used with both GridView and DetailsView
controls, allowing them to take advantage of the rich field templating functionality
offered by Dynamic Data. Figure 1.13 shows how this page looks at runtime.
 
 
Search WWH ::




Custom Search