ASP.NET MVC - Pass data between Views [closed]

0

I have two tables: Tb_1 and Tb_2 ; both have a id column and are related to each other in a Microsoft SQL database.

For example: I selected the # 2 record in Tb_1 . When you run the Create command, Tb_2 gets # 2 in your id field >

How do I do when I click the Create button on Tb_1 , send the same id strong> Tb_1 for Tb_2 ?

    
asked by anonymous 13.03.2018 / 19:27

1 answer

1

I was able to solve, if anyone wants a tip:

It was like this:

// GET: tb_visitas/Create
public ActionResult Create()
{
    ViewBag.id_broc = new SelectList(db.tb_brochuras, "id_broc", "descricao");
    ViewBag.id_g = new SelectList(db.tb_despertai, "id_g", "tema");
    ViewBag.id = new SelectList(db.tb_estrangeiros, "id", "nome");
    ViewBag.id_fol = new SelectList(db.tb_folhetos, "id_fol", "descricao");
    ViewBag.id_livros = new SelectList(db.tb_livros, "id_livros", "descricao");
    ViewBag.id_wp = new SelectList(db.tb_sentinela, "id_wp", "tema");
    return View();
}

Then I changed to this:

// GET: tb_visitas/Create
public ActionResult Create(tb_estrangeiros estrangeiros)
{
    ViewBag.id_broc = new SelectList(db.tb_brochuras, "id_broc", "descricao");
    ViewBag.id_g = new SelectList(db.tb_despertai, "id_g", "tema");
    ViewBag.id = new SelectList(db.tb_estrangeiros, "id", "nome", estrangeiros.id);
    ViewBag.id_fol = new SelectList(db.tb_folhetos, "id_fol", "descricao");
    ViewBag.id_livros = new SelectList(db.tb_livros, "id_livros", "descricao");
    ViewBag.id_wp = new SelectList(db.tb_sentinela, "id_wp", "tema");
    return View();
}
    
13.03.2018 / 23:04