Select a particular view for viewing - ASP. NET MVC

-1

I'm learning ASP.NET MVC and I came across a situation that would like the help of you.

I have a view that shows the result of a database query on the screen. Each record shown has an ID (ID), and I need to click change to hit something that is in the one that is being presented, so far so good.

However, for example, the first record shown is to change the records of table "A", the second record to change the data of table "C", the third of table "D", and so on. The problem is precisely this, there is a way to click on the Edit button, it points to which view corresponds to the error and open this view, ie program if the view has error type 1 opens the "A" view, if error type 2 opens the view "B" and so on.

    
asked by anonymous 25.07.2017 / 15:58

1 answer

0

You can do this using the View using Razor @ HTML.LinkAction, in addition to creating Action in the controller.

@Html.ActionLink("titulo do link", "QualActionQuer", "DeQualcontrollerQuer", new { id = "123" }, null)

Ex:

View

@Html.ActionLink("titulo do link A", "ActionTabelaA", "AlteraTabelaController", new { id = 1 }, null)
@Html.ActionLink("titulo do link B", "ActionTabelaB", "AlteraTabelaController", new { id = 2 }, null)
@Html.ActionLink("titulo do link C", "ActionTabelaC", "AlteraTabelaController", new { id = 3 }, null)
@Html.ActionLink("titulo do link D", "ActionTabelaD", "AlteraTabelaController", new { id = 4 }, null)

Controller

public class AlteraTabelaController : Controller
{
    public ActionResult ActionTabelaA()
    {
        return View();
    }

    public ActionResult ActionTabelaB()
    {
        return View();
    }

    public ActionResult ActionTabelaC()
    {
        return View();
    }

    public ActionResult ActionTabelaD()
    {
        return View();
    }
}
    
25.07.2017 / 17:06