M
moondaddy
I have a asp.net dropdownlist on a page and need to set the selected item to
a certain item in the list using the codebehind. For example, I have a list
of 4 different shipping methods in the list where the value attribute is the
primary key value from the database and has nothing to do with the index of
the item I want to select. I know I can select an item like this:
Me.cmbShipMethod.Items(3).Selected = True
but I will not know the index of an item, only its PK value which might be
1233445. I could probably loop the all the list items and when I find it,
set it to that index value, but that seems klunky. Isn't there a more
elegant way to do this?
a certain item in the list using the codebehind. For example, I have a list
of 4 different shipping methods in the list where the value attribute is the
primary key value from the database and has nothing to do with the index of
the item I want to select. I know I can select an item like this:
Me.cmbShipMethod.Items(3).Selected = True
but I will not know the index of an item, only its PK value which might be
1233445. I could probably loop the all the list items and when I find it,
set it to that index value, but that seems klunky. Isn't there a more
elegant way to do this?