I am newbie in ASP.NET MVC. I have a below requirement.
I need to show dynamically pie charts on the Dashboard page. I will decide total count of pie charts at run time. So, I have created a Partial View of the pie chart and a model class.
First, I will hit the database and fill data into model class. I din'd find any tutorial.
Controller Code :
public ActionResult _Dashboard()
{
try
{
_dashboard = new Dashboard();
var model = _dashboard.GetToolsUtilization();
return View(model);
}
catch (Exception ex)
{
throw ex;
}
finally
{ }
}
Tools class
public class Tools
{
public string toolName { get; set; }
public int used { get; set; }
public int free { get; set; }
}
_Dashboard.cshtml Page
<div class="col-lg-12">
@foreach (var item in Model)
{
<div class="dash-unit col-lg-3">
Html.Partial("~/Views/Shared/toolGaugeInfo.cshtml", item)
</div>
}
</div>
ToolGauageInfo.cshtml
@model NETMS.DAL.ToolGauageInfo
I think, Partial view page is fine. I will call controller on page load by ajax call. Now, I don't know how to return model from controller.
You will calculate number of pie charts and save it in a
List<PieChartModel>
or somrthing and you can create View that take@model List<PieChartModel>
and loop over list to display your partialview