Reputation: 71
So i have a program which adds pets to a database,
in this database have three tables: pets
, breeds
, species
When i add a pet i need to select a species using a dropdownlist speciesDropDownList
, and then again select a breed from another dropdownlist breedDropDownList
, however when i view the breed dropdownlist - it shows all breeds - not the breeds for the selected species from the previous dropdownlist
Question: How can i make the breed dropdownlist show only relevant breeds in relation to the previously selected species in species dropdownlist?
Example - when i select Cat
from speciesDropDownList
, i want breedDropDownList
to show only Persian
Screenshot of species dropdownlist
Screenshot of breed dropdownlist
Screenshot of both dropdownlists from inside visual studio
Screenshot showing both Breed and Species Tables data values
I am imagining a code such as:
SELECT BreedName FROM Breed WHERE Breed.Species = Species.Name
Upvotes: 0
Views: 303
Reputation: 46
You can have onChange event on your species dropdown to populate your breed dropdown..
This query should work -> SELECT BreedName FROM Breed WHERE Breed.Species = Species.Name
Upvotes: 1