mvc datatablerow grouping c#
Budget: $10 – $30 USD
i have this code and i need to make a group heading by department and then list the item number each department and the sum of the amount
ListtoDataTable lsttodt = new ListtoDataTable();
DataTable dt = lsttodt.ToDataTable(DeptSalesLists);
Session["dtSalesByDepartmentExport"] = dt;
if (dt.Rows.Count > 0)
{
strHTML.Append("<table class='table table-striped table-bordered table-hover dt-responsive' width='100%' id='sample_1' cellspacing='0' width='100%'>");
strHTML.Append("<thead>");
strHTML.Append("<tr>");
strHTML.Append("<th class='all' style='text-align: right'>ItemName</th>");
strHTML.Append("<th class='all'>Department</th>");
strHTML.Append("<th class='min-tablet' style='text-align: right'>Quantity</th>");
strHTML.Append("<th class='min-tablet' style='text-align: right'>Amount</th>");
strHTML.Append("</tr>");
strHTML.Append("</thead>");
strHTML.Append("<tbody>");
for (int i = 0; i < dt.Rows.Count; i++)
{
strHTML.Append("<tr>");
strHTML.Append("<td style='text-align: right'>" + Convert.ToString(dt.Rows[i]["ItemName"]).ToString() + "</td>");
strHTML.Append("<td>" + Convert.ToString(dt.Rows[i]["Dept_ID"]).ToString() + "</td>");
strHTML.Append("<td style='text-align: right'>" + Convert.ToDecimal(dt.Rows[i]["ASQuantity"]).ToString("F2") + "</td>");
strHTML.Append("<td style='text-align: right'>" + Convert.ToDecimal(dt.Rows[i]["TotalPrice"]).ToString("C", usaCulture) + "</td>");
strHTML.Append("</tr>");
}
strHTML.Append("</tbody>");
strHTML.Append("</table>");
}
else
{
strHTML.Append("<center>No data available in table</center>");
}
return Content(strHTML.ToString());
ListtoDataTable lsttodt = new ListtoDataTable();
DataTable dt = lsttodt.ToDataTable(DeptSalesLists);
Session["dtSalesByDepartmentExport"] = dt;
if (dt.Rows.Count > 0)
{
strHTML.Append("<table class='table table-striped table-bordered table-hover dt-responsive' width='100%' id='sample_1' cellspacing='0' width='100%'>");
strHTML.Append("<thead>");
strHTML.Append("<tr>");
strHTML.Append("<th class='all' style='text-align: right'>ItemName</th>");
strHTML.Append("<th class='all'>Department</th>");
strHTML.Append("<th class='min-tablet' style='text-align: right'>Quantity</th>");
strHTML.Append("<th class='min-tablet' style='text-align: right'>Amount</th>");
strHTML.Append("</tr>");
strHTML.Append("</thead>");
strHTML.Append("<tbody>");
for (int i = 0; i < dt.Rows.Count; i++)
{
strHTML.Append("<tr>");
strHTML.Append("<td style='text-align: right'>" + Convert.ToString(dt.Rows[i]["ItemName"]).ToString() + "</td>");
strHTML.Append("<td>" + Convert.ToString(dt.Rows[i]["Dept_ID"]).ToString() + "</td>");
strHTML.Append("<td style='text-align: right'>" + Convert.ToDecimal(dt.Rows[i]["ASQuantity"]).ToString("F2") + "</td>");
strHTML.Append("<td style='text-align: right'>" + Convert.ToDecimal(dt.Rows[i]["TotalPrice"]).ToString("C", usaCulture) + "</td>");
strHTML.Append("</tr>");
}
strHTML.Append("</tbody>");
strHTML.Append("</table>");
}
else
{
strHTML.Append("<center>No data available in table</center>");
}
return Content(strHTML.ToString());