[Solved] SQL Statement – Select data from database with condition – MVC4
First, move that code out of the view and put it in the Controller. You should avoid putting Data Access code in a View because you are breaking the MVC pattern. Second, if you move that code to an Action in your Controller, you can do this: public ActionResult Index() { var myModel = GetMyModel();//However … Read more