Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Can I retrieve data from database in razor view?
If yes, how to write it.
Posted

Irrespective of whether view is Razer or aspx, u can always retrieve data from database... Write an action method in controller. In that action method, write the logic to get data from database. Make use of ADO.NET concept. Assign data to a model. Return this model to associated Razer view. :). If u do not know writing code or how to implement, kindly go through some online tutorials on MVC
 
Share this answer
 
Yes, it's possible but it violates the separation of concerns. The View should be concerned only with the creation of the HTML to send to the browser.

If you need to send data to the View to create that HTML, the Controller should go get it and place it into the view model to be sent to the View.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900