Databases Reference
In-Depth Information
}
}
}
The OnInit method populates the list of items in the DropDownList control using a static
array of U.S. state abbreviations and initializes the validators by calling the
SetUpValidator method provided by the FieldTemplateUserControl base class. The
OnDataBinding method provides the initial selection for the DropDownList based on the
state value previously stored in the database, and the ExtractValues method returns the
new value selected by the user to the data source control when it is time to save the
customer entity in the database.
<unl:UnleashedControl runat=”server” DataField=”Region” UIHint=”State” />
With the new custom field template created, you can now modify the Customer entity
template as just shown to use it for the Region property instead of the default field
template.
NOTE
Value of the UIHint property of the DynamicControl class should not include the
_Edit suffix used in the name of the field template. As explained in Chapter 4,
Dynamic Data automatically adds this suffix to the UIHint value when looking for the
field template, and had you set UIHint to State_Edit , it would be looking for a field
template called State_Edit_Edit .
Implementing Interaction Between Field Templates
Unfortunately, as you start using the new State field template, you soon discover that it
does not work well for international customers. Northwind Traders does business with
customers in Europe also, but only United States and Canada use states, or more appropri-
ately, regions, in their mailing addresses. Moreover, for the United States and Canada, you
also need the users to see only the regions appropriate for a particular country. In other
words, the field template for the Region property of the Customer entity must somehow
work together with the field template for the Country property to provide the required
user experience.
You can start tackling this problem by renaming the custom field template from
State_Edit to Region_Edit to more accurately reflect that it is being used not only for
customers in the U.S., but in other countries as well. Because the list of regions is no
longer static, you cannot pretend to know all possible regions in all countries and need to
go back to using a TextBox as a data entry control. However, to keep data entry easy for
the most common countries, you can use the AutoCompleteExtender from the AJAX
 
 
Search WWH ::




Custom Search