clearing dropdownlist selected value

I have this problem when I try to assign selected value using codebehind, even though I already put the code:

or dropdownlist.selectedindex=-1
or dropdownlist.selectedindex=""

all throw error said it can’t have duplicate selected value.
now there are two way to clear the selected value, first by do it twice, like what is listed in bug section in Q327244 (;en-us;327244), like this:

dropdownlist.selectedvalue=-1 ‘this will change the selected value index to index number 0
dropdownlist.selectedvalue=-1 ‘this will clear all selected item

or add this code:



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s