I’ve got an SQL Database and I’m using ASP.net in C#.
I’ve got a drop-down box which has its selection of items databound to a table in the database. Basically, I need to get the ID of the selected record.
Not really sure what the best way to do this would be. I can only think of selecting the nth row by using the SelectedIndex property the drop-down box exposes.
ID is of type uniqueidentifier. Please note that an ID of incremental INT would not be of use because records may be deleted.
Did you assign which field value will be returned when the DropDown’s SelectedItem is changed? You should assign the field name to make sure the assigned field value returned when you select an item in your DropDown box. Try something like this-
Then use
DropDownList.SelectedValueto get your desired field value as the DropDown’s selection result. Hope this helps.