如何通过单击列标题对降序中的Table1进行排序 [英] How do I sort Table1 in Descending Order by clicking on the column heading
本文介绍了如何通过单击列标题对降序中的Table1进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试按降序排序Table1我点击列标题,Idt,没有任何反应。
HomeController.cs
I am trying to sort Table1 in Descending Order I click on the column heading, Idt, and nothing happens.
HomeController.cs
private testContext db = new testContext();
public List<Table1> thistable = new List<Table1>();
[HttpPost]
public ActionResult Index(int Idt)
{
var sortthistable = from s in db.Data1 select s;
sortthistable = sortthistable.OrderByDescending(s => s.Idt);
thistable = sortthistable.ToList();
return View(thistable);
}
Index.cshtml
Index.cshtml
@Html.ActionLink("Idt", "Index")
推荐答案
一个想法可以是 -
1.在查询字符串中传递排序信息
2.在操作方法中获取查询字符串作为参数
3.相应地对结果进行排序并返回视图。
这是一篇关于这个主题的非常好的文章
使用ASP.NET中的实体框架进行排序,过滤和分页MVC应用程序 [ ^ ]
希望,它有助于:)
An idea can be-
1. Pass sorting info in querystring
2. Get the querystring as parameter in the action method
3. Sort the result accordingly and return the view.
Here is a very good article on this topic
Sorting, Filtering, and Paging with the Entity Framework in an ASP.NET MVC Application[^]
Hopefully, it helps :)
这篇关于如何通过单击列标题对降序中的Table1进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文