如何保持搜索值删除后MVC [英] How to keep search value after delete in MVC

查看:66
本文介绍了如何保持搜索值删除后MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的控制器具有搜索条件

My Controller has search criteria

     // GET: 
    public ActionResult Index(int? page, string site, string user, string department,      string status, string TransactionDate)
    {
      /// Filter by search criteria
      return view(object.ToList());
    }

这是我的删除操作。

// POST:
    [HttpPost]
    public ActionResult Delete(string id = null)
    {
        var table = Table.Find(id);
        if (table == null)
        {
            return HttpNotFound();
        }
        return View(table);
    }

如何保持搜索值和搜索返回值的视图过滤器。

How to keep search value and return the view filter by search value.

谢谢,
硅星期四

Thanks, Si Thu

推荐答案

MVC使用,可以用来作为一个水桶在那里你可以转储只需要对下面的请求数据的TempData的值。

MVC uses a TempData value that can be used as a bucket where you can dump data that is only needed for the following request.

所以,你会使用这样的动作方法:

So you'd use it like this in your action method:

TempData["searchId"] = id;

和使用相同的的TempData [searchId] 语法您的视图进行检索。

And retrieve it in your view using the same TempData["searchId"] syntax.

如果我的解释不充分(极有可能)解释它,那么<一个href=\"http://www.rachelappel.com/when-to-use-viewbag-viewdata-or-tempdata-in-asp.net-mvc-3-applications\"相对=nofollow>这篇文章可能会提供一个更好的主意。

If my explanation doesn't explain it adequately (highly probable), then this article might offer a better idea.

这篇关于如何保持搜索值删除后MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆