Hi all, I have a dropdownlist that I populate like this
My problem is I want to set the selected index based on the string value of the dropdownlist, but I am using value to store the index.
I made a loop
But I think there should be a more efficent way. Any ideas?
Sorry if this is the most repeated question, but I see a lot of people using value to store the display string, but I am using value to store the primary key of my DB so I don't have to lookup again.
Thanks again
CJB
Code:
eventDL.DataSource = sqlSelect("Select * from [event]")
eventDL.DataTextField = "eventName"
eventDL.DataValueField = "pk_Event"
My problem is I want to set the selected index based on the string value of the dropdownlist, but I am using value to store the index.
I made a loop
Code:
eventDL.DataSource = sqlSelect("Select * from [event]")
eventDL.DataTextField = "eventName"
eventDL.DataValueField = "pk_Event"
But I think there should be a more efficent way. Any ideas?
Sorry if this is the most repeated question, but I see a lot of people using value to store the display string, but I am using value to store the primary key of my DB so I don't have to lookup again.
Thanks again
CJB