I've been using the following controls for a while now and thought it about time I made them into templates - so find a suitable patch attached!
EntityDropDownList - Derives from a DropDownList, but adds a few extra features such as the ability to add a null item (adds a child ListItem), make it readonly(converts it to a label), make the control required (uses a RequiredFieldValidator) and it supports type ahead (javascript).
example use:
<data:EntityDropDownList runat="server" ID="myfieldDDL" DataSourceID="productsDataSource" DataTextField="ProductName" DataValueField="ProductID"
AppendNullItem="true"
NullItemText="<select a value>"
Required="true"
ReadOnly="false"
FriendlyName="My drop down field"
ErrorText="*"
RequiredErrorMessage="This drop down is required"
CaseSensitiveKeySort="true"
/>
BoundEntityDropDownField - As above but derived from BoundField so that it can be used within a grid (EntityGridView). It caches the data so that it is only read once for all the bound rows.
example use:
<data:EntityGridView runat="server" ID="gridView" DataSourceID="productsDataSource"
DataKeyNames="ProductID"
AutoGenerateColumns="false"
AutoGenerateEditButton="true"
AllowPaging="true"
AllowSorting="true">
<Columns>
<asp:BoundField DataField="ProductID" HeaderText="Product ID" ReadOnly="True" SortExpression="ProductID" />
<asp:BoundField DataField="ProductName" HeaderText="Product Name" SortExpression="ProductName" />
<data:BoundEntityDropDownField DataField="SupplierID" HeaderText="Supplier" SortExpression="SupplierID"
DataSourceID="suppliersDataSource"
DataTextField="CompanyName"
DataValueField="SupplierID"
AppendNullItem="true" />
<data:BoundEntityDropDownField DataField="CategoryID" HeaderText="Category" SortExpression="CategoryID" DataSourceID="categoriesDataSource" DataTextField="CategoryName" DataValueField="CategoryID" AppendNullItem="true" />
</Columns>
</data:EntityGridView>
<data:ProductsDataSource runat="server" ID="productsDataSource" sort="ProductName" EnableSorting="true" EnablePaging="true" SelectMethod="GetPaged" />
<data:CategoriesDataSource runat="server" ID="categoriesDataSource" Sort="CategoryName" />
<data:SuppliersDataSource runat="server" ID="suppliersDataSource" Sort="CompanyName" />
hth
swin
-------------------------------------------------
Member of the .NetTiers team
-------------------------------------------------