So I have this:

private void GetSuppliersList()
            ds = oDAL.GetSuppliersList();
            cmbSupplier.DataSource = ds.Tables["SuppliersHeader"];
            cmbSupplier.DisplayMember = "SupplierName";
            cmbSupplier.ValueMember = "SupplierID";

And I need to display SupplierAddress from my SQL database into a textbox so I thought I might need to get the ID (Supplier ID) of the SelectedValue (Supplier Name) from my combobox to get its SupplierAddress and display it at the event of SelectedIndexChanged. Thanks in advance!

Edited by nickurooo: Lacking question mark

4 Years
Discussion Span
Last Post by castajiz_2

if cmbSupplier.SelectedIndex = -1 nothing has been selected
otherwise SupplierID is cmbSupplier.SelectedValue


-When your event fires just store the supplier ID into a variable;
-Use that variable in your SQL query for example--> select address from table where id=@some_number. Since every value is unique you will get only one result. After you read the executed query table store your address in a variable or display it in the textbox immediatly. Ofcourse you must open a connection, write the sql query, execute the reader so that you can achieve the desired.
If a problem occures along just post you code here...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.