Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DropDownList Question

Reply
Thread Tools

DropDownList Question

 
 
Will Lastname
Guest
Posts: n/a
 
      09-12-2005
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.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UmFrZXNoIFJhamFu?=
Guest
Posts: n/a
 
      09-12-2005
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.
>
>

 
Reply With Quote
 
 
 
 
darrel
Guest
Posts: n/a
 
      09-12-2005
> 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


 
Reply With Quote
 
Will Lastname
Guest
Posts: n/a
 
      09-12-2005
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!

 
Reply With Quote
 
darrel
Guest
Posts: n/a
 
      09-12-2005
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DropDownList inside GridView: How to set SelectedIndex for the DropDownList? keithb ASP .Net 1 11-01-2006 05:24 AM
GridView: Filter DropDownList for another DropDownList =?Utf-8?B?SnVhbmpv?= ASP .Net 0 12-29-2005 07:44 AM
GridView: Filtr DropDownList from another DropDownList =?Utf-8?B?SnVhbmpv?= ASP .Net 0 12-23-2005 01:31 PM
databinding a Dropdownlist to another dropdownlist tshad ASP .Net 8 10-19-2005 10:00 PM
Using a data-bind dropdownlist to populate another data-bind dropdownlist mr2_93 ASP .Net 1 10-02-2005 05:07 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57