jen wrote:
i have select query that returns multiple records and populates a
combobox/pulldown.
once a selection from the pulldown is selected, i need to reference two
or three fileds from the previous query related to that selection.
What you're looking for is what's unfortunately missing from the
ComboBox in the .NET framework: a Tag field on a combo box item that
allows you to connect it back to a business object or data row.
There are several ways to do this.
The simplest is to display the combo box items in the same order that
they are in the DataRowCollection, and use the combo box's
SelectedIndex to find the data row. So, if the user chooses an item
with index 5, you go and get the data row at index 5 (the sixth data
row) and that's the one that was chosen.
If you need a particular ordering for the combo box items, put a
DataView on top of the DataTable, and then populate the combo box from
the DataView.
Another way to do it is to put your data in objects and add them to the
combo box using its .Items.Add() method. You then set the ComboBox's
DisplayMember property to the name of the object property (as a string)
that the combo box should display to the user. So, for example, if your
data rows represent customers, you might say
comboBox1.DisplayMember = "Name";
to display the .Name property of the customer objects as the combo box
item text.
Now when the user selects an item in the combo box, you can use
SelectedItem to get the object they selected.