Databases Reference
In-Depth Information
When creating custom entity templates, you have a good control over placement of the
field templates. You can arrange
DynamicControl
instances using HTML
table
or
div
tags
and CSS if that is what you prefer. However, there is no obvious way to control appear-
ance of controls within the field templates. Take a look at Figure 10.1, which shows a web
page generated by the custom entity template for the Customer entity.
FIGURE 10.1
Web page with default address field template.
Notice how the Address text box cuts off a long string even though there is plenty of
space available on the right side of the control. Had this page been built with traditional
ASP.NET controls, you could have easily changed the
Columns
property of the address
TextBox
control and made it wider. How do you configure a field template instantiated by
a
DynamicControl
?
Specifying a Field Template Explicitly
You can choose a specific field template to be created by a
DynamicControl
by setting its
UIHint
property. In this example, you might want to try using the
MultilineText
field
template for the Address property as it creates a wider
TextBox
in
Edit
mode:
<asp:DynamicControl runat=”server” DataField=”Address”
UIHint= ”MultilineText”
/>
The
UIHint
property is usually assigned in page or template markup. However, it can be
initialized programmatically as well, by handling the
Init
event of the
DynamicControl
as
shown next:
protected void DynamicControl_Init(object sender, EventArgs e)
{
var dynamicControl = (DynamicControl)sender;
dynamicControl.UIHint = “MultilineText”;
}