Reputation: 1397
I'm using forms and i get names from database to combobox. (Table Person(idPerson,name,age))
this.personTableAdapter.Fill(this.test_pmDataSet.Person);
How can i get id from person, who i choose in combobox?
Upvotes: 2
Views: 824
Reputation: 708
depending on which db you use:
i suppose you have your combobobox populate with the personnames out of your DB
get the name of the person by:
string personsname= combobox1.selectedValue;
Get the id of this person by a query (sql: select idPerson from Persons where name = personsname;)
Upvotes: 3
Reputation: 11223
You probably need the "SelectedValue" property of your combobox control.
Upvotes: 6