Using ASP.NET MVC with C#, how do you pass some database records to a View and display them in table form?
I need to know how I can transfer/pass some rows of record
If you dont have to use an sql reader would it not be easier to have the Controller like this.
Controller.cs
private ConnectContext db = new ConnectContext();
public ActionResult Index()
{
return View(db.Tv.ToList());
}
ConnectContext.cs
public class ConnectContext : DbContext
{
public DbSet Student{ get; set; }
}
This way your connection string will be in your web.config and the View + Model will remain the same.