0

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());
    }

This is my delete action

// 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

Si Thu
  • 1,185
  • 1
  • 13
  • 21

1 Answers1

1

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;

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

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

Phil.Wheeler
  • 16,748
  • 10
  • 99
  • 155