The problem was actually a little obscure and you are correct...if I had
posted the rest of the code somebody would have certainly pointed out the
problem...
I was doing this in the binding code:
While dtrReader.Read
If Not IsDBNull(dtrReader("ListDisplay")) Then
AddListitem(ddlActionRequestedBy, dtrReader("ListDisplay"),
dtrReader("FullName"))
AddListitem(ddlActionAuthorizedBy, dtrReader("ListDisplay"),
dtrReader("FullName"))
AddListitem(ddlActionAssignedTo, dtrReader("ListDisplay"),
dtrReader("FullName"))
AddListitem(ddlActionCompletedBy, dtrReader("ListDisplay"),
dtrReader("FullName"))
AddListitem(ddlCreditAuthorizedBy, dtrReader("ListDisplay"),
dtrReader("FullName"))
AddListitem(ddlCreditToBePerformedBy, dtrReader("ListDisplay"),
dtrReader("FullName"))
AddListitem(ddlCreditRequestedBy, dtrReader("ListDisplay"),
dtrReader("FullName"))
AddListitem(ddlCreditPerformedBy, dtrReader("ListDisplay"),
dtrReader("FullName"))
AddListitem(ddlResolvedBy, dtrReader("ListDisplay"), dtrReader("FullName"))
AddListitem(ddlResolutionProposedBy, dtrReader("ListDisplay"),
dtrReader("FullName"))
AddListitem(ddlResolutionAuthorizedBy, dtrReader("ListDisplay"),
dtrReader("FullName"))
AddListitem(ddlResolutionAssignedTo, dtrReader("ListDisplay"),
dtrReader("FullName"))
AddListitem(ddlResolvedApprovedBy, dtrReader("ListDisplay"),
dtrReader("FullName"))
AddListitem(ddlFollowUpAssignedTo, dtrReader("ListDisplay"),
dtrReader("FullName"))
AddListitem(ddlFollowupApprovedBy, dtrReader("ListDisplay"),
dtrReader("FullName"))
AddListitem(ddlFollowupCompletedBy, dtrReader("ListDisplay"),
dtrReader("FullName"))
AddListitem(ddlAccountantNotified, dtrReader("ListDisplay"),
dtrReader("FullName"))
End If
End While
The problem was that .Net treated those list items as references and not
values. Once I changed that then presto...everything worked fine.
Thanks!
Ron
"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:uH**************@TK2MSFTNGP03.phx.gbl...
First of all, I think it would help if you posted all of your code.
Second, I believe that the intended way to programmatically change the
selected index in a codebehind was to do something like the following:
ddlActionRequestedBy.SelectedIndex = 2
Using your technique works, as long as all the Items are set to
Selected=False beforehand, otherwise you will be creating a point in which
multiple Items have Selected=True, causing the exception that you
mentioned. I do not have an explanation for all the dropdownlists having
the same selected value, but it would certainly help me and anyone else
reading your posts if you posted the code. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
"RSH" <wa*************@yahoo.comwrote in message
news:O0**************@TK2MSFTNGP04.phx.gbl...
>Hi,
I am having this very bizarre occurance with 4 dropdown lists on my ASP
.Net page.
Each control has its own unique id. When the user selects a value from
each of the dropdownlists it is written correctly to the database.
HOWEVER...When setting the SelectedIndex property of each of the controls
in the codebehind (.net 1.1) I get an exception "A dropdownlist can not
have multiple selections." This is very odd because I am literally
seeting each control as follows:
ddlActionRequestedBy.Items(2).Selected = True
ddlActionAuthorizedBy.Items(7).Selected = True
ddlActionCompletedBy.Items(12).Selected = True
ddlActionAssignedTo.Items(80).Selected = True
So I stepped through the code to try and see what happens...and what
happens is that when I set the Selected property to true for one control
all of the controls assume the same SelectedIndex. So to verify my
assumption I commented out all but the first
"ddlActionRequestedBy.Items(2).Selected = True" so I would have expected
that only that control have a value selected on page load...BUT to my
surprise each of the 4 dropdownlists had the SAME selected value. I have
triple checked all code and nowhere else on the page am I setting
selectedvalues...i dont get it.
What am I missing????
Thanks!
Ron