DropDownList Question

Discussion in 'ASP .Net' started by Will Lastname, Sep 12, 2005.

  1. My application has a series of dropdownlists with AutoPostBack set to
    True and IndexChanged handlers as well. All of the dropdownlists are
    bound and dynamically populated.

    Is there a way to manually add an entry to a dropdownlist that is
    bound? The reason I ask is because if the first item is the one the
    user wants to select it is not able to postback since it is already
    selected.
    Will Lastname, Sep 12, 2005
    #1
    1. Advertising

  2. Hi Will,

    You could just add a new item into the underlying data source.

    For example, if you are using a datatable as the datasource, add a new row
    to it with the topmost value to display, and then bind to the drop down.

    You could also set up client side scripts so that a client-side validation
    would ensure the user has made a valid selection.

    Does this help?
    --
    HTH,
    Rakesh Rajan
    MVP, MCSD
    http://www.msmvps.com/rakeshrajan/



    "Will Lastname" wrote:

    > My application has a series of dropdownlists with AutoPostBack set to
    > True and IndexChanged handlers as well. All of the dropdownlists are
    > bound and dynamically populated.
    >
    > Is there a way to manually add an entry to a dropdownlist that is
    > bound? The reason I ask is because if the first item is the one the
    > user wants to select it is not able to postback since it is already
    > selected.
    >
    >
    =?Utf-8?B?UmFrZXNoIFJhamFu?=, Sep 12, 2005
    #2
    1. Advertising

  3. Will Lastname

    darrel Guest

    > Is there a way to manually add an entry to a dropdownlist that is
    > bound?


    Yes.

    DropDownListNavigation.DataBind()
    DropDownListNavigation.Items.Insert(0, New ListItem("Pick An Option",
    "null"))

    -Darrel
    darrel, Sep 12, 2005
    #3
  4. Thanks to both of you. I am sorry to say that I am still getting an
    error stating that I can't modify this list when a datasource property
    is set. Thanks anyway!
    Will Lastname, Sep 12, 2005
    #4
  5. Will Lastname

    darrel Guest

    > Thanks to both of you. I am sorry to say that I am still getting an
    > error stating that I can't modify this list when a datasource property
    > is set. Thanks anyway!


    Did you use the code example I showed you? That seems to work fine in my
    application. What is the exact error you get?

    -Darrel
    darrel, Sep 12, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mr2_93
    Replies:
    1
    Views:
    3,581
    mr2_93
    Oct 2, 2005
  2. tshad
    Replies:
    8
    Views:
    2,205
    tshad
    Oct 19, 2005
  3. =?Utf-8?B?SnVhbmpv?=

    GridView: Filtr DropDownList from another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 23, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,846
    =?Utf-8?B?SnVhbmpv?=
    Dec 23, 2005
  4. =?Utf-8?B?SnVhbmpv?=

    GridView: Filter DropDownList for another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 29, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,282
    =?Utf-8?B?SnVhbmpv?=
    Dec 29, 2005
  5. keithb
    Replies:
    1
    Views:
    11,910
    shauns1
    Nov 1, 2006
Loading...

Share This Page