CodeSmith Community
Your Code. Your Way. Faster!

New EntityDropDownList and BoundEntityDropDownField controls

Latest post 08-18-2007 12:10 PM by swin. 8 replies.
  • 02-19-2007 9:40 AM

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 924
    • Points 34,750

    New EntityDropDownList and BoundEntityDropDownField controls

    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 -------------------------------------------------
    • Post Points: 75
  • 02-19-2007 10:07 AM In reply to

    • mike123
    • Top 10 Contributor
    • Joined on 02-25-2005
    • Toronto, Ontario
    • Posts 734
    • Points 17,040

    Re: New EntityDropDownList and BoundEntityDropDownField controls

    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
    --------------------------------------------------------------

    • Post Points: 5
  • 02-19-2007 6:13 PM In reply to

    • BioMash
    • Top 50 Contributor
    • Joined on 06-16-2005
    • Western Australia
    • Posts 79
    • Points 1,870

    Re: New EntityDropDownList and BoundEntityDropDownField controls

    Yep, thats excellent, thanks swin Big Smile

     

    • Post Points: 35
  • 02-22-2007 2:43 AM In reply to

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 924
    • Points 34,750

    Re: New EntityDropDownList and BoundEntityDropDownField controls

    Thanks guys.

    Hey Mike, good job on adding them to the web admin so quickly.

    Cheers

    swin 

    ------------------------------------------------- Member of the .NetTiers team -------------------------------------------------
    • Post Points: 35
  • 02-22-2007 10:30 AM In reply to

    • dedbauer
    • Not Ranked
    • Joined on 01-03-2007
    • Posts 2
    • Points 40

    Re: New EntityDropDownList and BoundEntityDropDownField controls

    Is there a reason the SelectedValue does not show up in IntelliSense for this control?
    • Post Points: 35
  • 02-22-2007 10:50 AM In reply to

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 924
    • Points 34,750

    Re: New EntityDropDownList and BoundEntityDropDownField controls

    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!

    hth

    swin 

    ------------------------------------------------- Member of the .NetTiers team -------------------------------------------------
    • Post Points: 35
  • 02-22-2007 12:28 PM In reply to

    • mike123
    • Top 10 Contributor
    • Joined on 02-25-2005
    • Toronto, Ontario
    • Posts 734
    • Points 17,040

    Re: New EntityDropDownList and BoundEntityDropDownField controls

    The DesignerSerializationVisibility attribute is used to suppress the visibility in design-time. The question is why Wink

            [Browsable(false)]
            [DesignerSerializationVisibility(0)]
            [Themeable(false)]
            [DefaultValue("")]
            [Bindable(true, 1)]
            public virtual string SelectedValue { get; set; }

    Mike Shatny
    --------------------------------------------------------------
    Member of the .netTiers team http://www.nettiers.com
    --------------------------------------------------------------

    • Post Points: 35
  • 08-02-2007 11:53 AM In reply to

    • JJmartin
    • Top 25 Contributor
    • Joined on 05-22-2006
    • Phoenix, AZ
    • Posts 164
    • Points 3,275

    Re: New EntityDropDownList and BoundEntityDropDownField controls

    It would be great if this stuff was added to the documentation wiki

     

    -Jeff Martin C# MCSD
    • Post Points: 35
  • 08-18-2007 12:10 PM In reply to

    • swin
    • Top 10 Contributor
    • Joined on 06-14-2006
    • London, UK
    • Posts 924
    • Points 34,750

    Re: New EntityDropDownList and BoundEntityDropDownField controls

    Done!, although help on the wiki is always welcomeWink

    swin

    ------------------------------------------------- Member of the .NetTiers team -------------------------------------------------
    • Post Points: 5
Page 1 of 1 (9 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems