Get data from a model and display it as dropdown on client side in Razor
Hi, how do I retrieve data in a database from a model and show it in as my dropdown values in my razor view? For example, I have model called "Block", and I have a model called "ClassroomLocation", then on client side, there's a dropdown with "Block" as selection. But the values I'm not sure how to generate it based on the data stored inside "Block".
Do I have to use something called model binding? These two models are also non-relational to each other.
2 Replies
So you successfully grabbed the data from backend right
Since it's a drop-down probably like a list of block
Then yeah bind that
@friedice Is it the
[BindProperty]
attribute? If so, which model do I put the "bind" on? I'm assuming it's the "Block" model right?