I would like to sort the order of the table by the onclick on the heading of the column (Link). The code is as below,
Controller Code
public ActionResult StockStatus(int? id)
{
List data = new List();
if (id.HasValue)
{
data = db.Items.Where(d => d.InStock.Value d.ItemName).ToList();
ViewBag.LesserThan = id;
}
else
{
data = db.Items.OrderBy(d => d.ItemName).ToList();
}
return View(data);
}
public ActionResult StockStatus(int id)
{
var sold = db.Sales.Include(d => d.Items).Include(d => d.Customers).Where(d => d.ItemId == id).OrderByDescending(d => d.InvoiceId).ThenBy(d => d.Items.ItemName).ToList();
return View(sold);
}
Can any one of you please help me in this!!