public ActionResult Index() { ViewBag.Message = "Welcome to ASP.NET MVC!"; CarModels cm = new CarModels(); List <Cars> model = cm.getAllCars(); //GridView gv = new GridView(); //gv.DataSource = model; //gv.DataBind(); //Session["Cars"] = gv; return(View(model)); }
public ActionResult Download() { CarModels cm = new CarModels(); List <Cars> model = cm.getAllCars(); GridView gv = new GridView(); gv.DataSource = model; gv.DataBind(); return(new DownloadFileActionResult(gv, "Cars.xls")); //if (Session["Cars"] != null) //{ // return new DownloadFileActionResult(gv, "Cars.xls"); //} //else //{ // return new JavaScriptResult(); //} }