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?

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.