List data in a Dropdown related to the result of another Dropdown

Asked

Viewed 47 times

0

I’m rephrasing that question, because it must not have been very clear. What I want is this:

inserir a descrição da imagem aqui

Choose a restaurant at Dropdown, and the next dropdown, list the times that were registered by that restaurant.

Here is my Controller:

[HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult Create([Bind(Include = "EscolhaID,UsuarioID,HorarioID,RestauranteID")] EscolhaReserva escolhaReserva)
    {
        if (ModelState.IsValid)
        {
            int id = Convert.ToInt32(Session["ID"]);
            escolhaReserva.UsuarioID = id;
            escolhaReserva.Usuario = db.Usuarios.Find(id);

            db.EscolhaReservas.Add(escolhaReserva);
            db.SaveChanges();
            return RedirectToAction("Index");                             
        }

        ViewBag.HorarioID = new SelectList(db.Horarios, "HorarioID", "HorarioFinal", escolhaReserva.HorarioID);
        ViewBag.RestauranteID = new SelectList(db.Restaurantes, "RestauranteID", "Nome", escolhaReserva.RestauranteID);
        ViewBag.UsuarioID = new SelectList(db.Usuarios, "UsuarioID", "Nome", escolhaReserva.UsuarioID);
        return View(escolhaReserva);
    }

I want to make sure that, when clicking on the Restaurant Dropdown, it shows the respective schedules. Any idea?

  • Allan rephrasing the question will not bring you the answer and probably your question will be marked as duplicate. Your other question is also not very clear, you need to be more objective and show how this tetando display the restaurant schedules. It would be interesting if you put up your code.

  • from what I understand, each restaurant has its schedules you want according to the restaurant that the person choose to show the schedules ?

  • edit the post by putting like this your tables, to make it easier to help you

  • Ready. I edited it.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.