i have create class with function to return DataTable
namespace Office365
{
public class Office365
{
public DataTable GetQAData()
{
return Datatable;
}
}
}
this function use in Controlller and render data using ViewBag.Content like this
In .cshtml
@Html.Raw(ViewBag.QAData)
In Controller Code :
using Office365;
Office365 con = new Office365();
StringBuilder sb = new StringBuilder();
DataTable dt = con.GetQAData();
int i = 1;
foreach (DataRow dr in dt.Rows)
{
sb.append("<div></div>")
}
ViewBag.QAData = sb.ToString();
but is this possible to call class object on .cshtml and render my DataTable into Div? I means directly write code in .cshtml
I would create a ViewModel with a collection of your rows.
Then from the page I will cycle trough it and create the html.
Something like this
From controller
From the view
I hope you get the idea