如何通过单击列标题对降序中的Table1进行排序

编程入门 行业动态 更新时间:2024-10-28 09:25:09
本文介绍了如何通过单击列标题对降序中的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进行排序

本文发布于:2023-11-04 06:42:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1557223.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单击   标题   降序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!