Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

assign combobox value to iforeign key field

Status
Not open for further replies.

p27br

Programmer
Aug 13, 2001
516
GB
Hello

I am new to visual studio development and i am having trouble with
the following :
I have a form with a combobox :
Code:
            this.cboCivilite.DataSource = DataRepository.CiviliteProvider.GetAll();
            cboCivilite.DisplayMember = CiviliteColumn.Description.ToString();
            cboCivilite.ValueMember = CiviliteColumn.IdCivilite;

and I want that when the user selects a value in the combobox, the selected value will be saved in the database record field.

I tried this :
Code:
            part.IdCivilite = cboCivilite.SelectedValue;

but this property is an object and the id field is an int.

how should this be done ?

thanks
 
int myvalue = Convert.ToInt32(cboCivilite.SelectedValue.ToString());

part.IdCivilite = myvalue;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top