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.
<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
swin,
That is awesome! I have applied the patch on your behalf (rev. 490)
Mike Shatny--------------------------------------------------------------Member of the .netTiers team http://www.nettiers.com--------------------------------------------------------------
Yep, thats excellent, thanks swin
Thanks guys.
Hey Mike, good job on adding them to the web admin so quickly.
Cheers
It's because it doesn't appear in the base ASP.Net DropDownList.
I don't know why it doesn't appear - I guess Microsoft might know!
The DesignerSerializationVisibility attribute is used to suppress the visibility in design-time. The question is why
[Browsable(false)] [DesignerSerializationVisibility(0)] [Themeable(false)] [DefaultValue("")] [Bindable(true, 1)] public virtual string SelectedValue { get; set; }
It would be great if this stuff was added to the documentation wiki
Done!, although help on the wiki is always welcome