cboClients.DataSource = oClients.Clients; // this is your DataTable, I assumeThen you want to set both a DisplayMember *and* a ValueMember. The ValueMember will be set to your PK:
cboClients.DisplayMember = "clientname"; cboClients.ValueMember = "ClientKey";Now, as far as getting the Value that's been selected by the user, you can do it this way:
int iClientKey = (int)cboClients.SelectedValue;Or, if you have DataBound your Combo, you don't have to do anything ... the value will automatically get put into the column you've data bound to.
cboClients.DataBindings.Add("SelectedValue", MyDataSet.MyTable, "MyKeyColumn");Make sense?
>cboClients.DataSource = oClients; // oClients is a DataSet >cboClients.DisplayMember = "Clients.clientname"; >cboClients.SelectedIndex = 0; > >>
>int iIndex = cboClients.SelectedIndex; >DataSet oClients = (DataSet)cboClients.DataSource; >int iClientKey = Convert.ToInt32(oClients.Tables["Clients"].Rows[iIndex]["ClientKey"]); >