You don't need to use entity framework to use MVC - you can use whatever data strategy you like. In your case, just make sure you've got the
MySql.Net Connector[
^]
As far as using a standard
ASP.Net Gridview[
^], you wouldn't use this in your MVC views. Instead, you should be returning data you want displayed in a Grid in your Model - this will usually be an Enumerable list of objects e.g.
public class GridDataModel
{
public int Id { get; set; }
public string Description { get; set; }
public System.DateTime ItemDate { get; set; }
public decimal SpentValue { get; set; }
}
public class HomeController : Controller
{
public ActionResult Index()
{
var model = GetHomePageModel();
return View(model);
}
private System.Collections.Generic.List<GridDataModel> GetHomePageModel()
{
var model = new System.Collections.Generic.List<GridDataModel>();
for (int i = 0; i < 30; i++)
{
var item = new GridDataModel
{
Id = i,
Description = string.Format("Item number {0}", i),
ItemDate = System.DateTime.Today,
SpentValue = (100 * i)
};
model.Add(item);
}
return model;
}
}
In your view, you set the view to expect data of this type by specifying the model (Razor syntax) and render your view however you like. You could simply render a table and use
jQuery DataTables[
^] to make it into a grid.
@model List<GridDataModel>
@{
Layout = "SomeMasterLayout.cshtml";
}
<div class="yourpage">
<div class="grid-data">
@foreach (var item in Model)
{
}
</div>
</div>
Or, you could look at something like
Telerik MVC Controls [
^] which would allow you to do something like this
@(Html.Telerik().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(o => o.Id).Width(100);
columns.Bound(o => o.Description).Width(200);
columns.Bound(o => o.ItemDate).Format("{0:MM/dd/yyyy}").Width(120);
columns.Bound(o => o.SpentValue);
})
)