N
Nicolae Fieraru
Hi All,
I have a database with two tables. One is called tblMainCategory and the
other one tblCategory. The tblMainCategories has fields Index1 and
MainCategory.
The tblCategory has Index2, MainCategoryId and Category.
I have a form with two comboboxes. I want to populate the first combobox
with the strings from MainCategory field. Then, when I select one of the
values from the dropdown, I want to populate the second combobox only with
those records.
I decided to try first using datareader. I can populate the first combobox.
But then I realised I need the value of the Index1 from tblMainCategories,
in order to be able to query the elements for the second combobox. I suppose
I could use another query, an ExecuteScalar to retrieve the corresponding
Index1 for MainCategory which was chosen from the dropdown.
Is there a simpler way than this one? For example I can see that a combobox
has a ValueMember property and a DisplayMember property. Is that a list or
what? If it is a list, then I can add the Index1 from the query. I tried
with ComboBox->ValueMember->Items->Add, but it doesn't work...
Regards,
Nicolae
I have a database with two tables. One is called tblMainCategory and the
other one tblCategory. The tblMainCategories has fields Index1 and
MainCategory.
The tblCategory has Index2, MainCategoryId and Category.
I have a form with two comboboxes. I want to populate the first combobox
with the strings from MainCategory field. Then, when I select one of the
values from the dropdown, I want to populate the second combobox only with
those records.
I decided to try first using datareader. I can populate the first combobox.
But then I realised I need the value of the Index1 from tblMainCategories,
in order to be able to query the elements for the second combobox. I suppose
I could use another query, an ExecuteScalar to retrieve the corresponding
Index1 for MainCategory which was chosen from the dropdown.
Is there a simpler way than this one? For example I can see that a combobox
has a ValueMember property and a DisplayMember property. Is that a list or
what? If it is a list, then I can add the Index1 from the query. I tried
with ComboBox->ValueMember->Items->Add, but it doesn't work...
Regards,
Nicolae