0

I have a table with some information(view is called Index) , an add button and an edit button (which is supposed to send me to some other page and populate it with the object i want to edit)(view is call AddTest) When i select one row and i click edit i am redirected right here which is ok

public ActionResult EditTest(int? id)
{
    Test t= (id.HasValue) ? new Test_Service().GetByID(Convert.ToInt32(id)) : new Test();
    TempData["currentTest"] = t;
    return RedirectToAction("AddTest",(Test)TempData["currentTest"]);
}

I get the corresponding object and i am redirected right here which is ok

[AcceptVerbs(HttpVerbs.Get)]
public ActionResult AddTest()
{
    if (TempData["currentTest"] == null)
        TempData["currentTest"] = new Test();
    return View((Test)TempData["currentTest"]);
}

The problem is that i don't get to see the AddTest View although i send to it the correct data and if put a breakpoint in the view i can see that data gets there.
What i'm i doing wrong?

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by boguss
0

I think that wasn;t the best approach so..how would you solve this ?

You have a view with a grid with some records and two buttons (new + edit). When a button is clicked you are redirected to a second view passing the selected object for editing it, or passing nothing so you must fill in the details.

I am tight to this situation, i mean having that grid and two buttons even there may be better solutions.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.