c# - Set global variable from database -


I'm new to the new MVC, I'm working on Visual Studio 2012. I just want to get data from the database table, the controller and store this value in different variables. For example:

  Public Class Test Controller {Public Actioncell Testing Method () {var model = some LINQ code; }}   

Now I want to store this model value in different variables such as string , int etc. is required.

First you mvc 4 . There are lots of tutorials on the Internet

Here are some sample codes:

In your controller:

  public class testController {public activity} testMethod ( ) Get data from the database using {ViewBag.someData = / Linq or SQL Query // You can see the model / model view in View (model)}}   

( Cshtml) :: @ {var someData = ViewBag.someData; // Now you can use this data in your CSSML file}

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -