Selecting Suppliers by Fancy Name

Asked

Viewed 78 times

2

I have a PRODUCT registration form and there is a relationship with the SUPPLIER table, as shown in the image below:

inserir a descrição da imagem aqui

Which click on the SEARCH VENDOR button will appear this View

inserir a descrição da imagem aqui

Now I need to develop a text box that when typing a value it looks for all SUPPLIERS that contain a FANCY NAME as typed in the text box.

This Controller shows all vendors, but I only want the ones with FANCY NAME typed in the text box:

public ActionResult Index()
    {
        try
        {
            using (SistemaDBEntities db = new SistemaDBEntities())
            {
                return View(db.Fornecedor.Where(s => s.Ativo == true).ToList());
            }
        }
        catch (Exception)
        {

            throw;
        }

    }
  • J.C. Galhard, you want each time you type in the text box to be searched or typed and then searched?

  • Then I would research

1 answer

3


I so revoked my problem:

[HttpPost] 
public ActionResult Index(string sConsulta)
{
    var consulta = db.Fornecedor.Where(s => s.NomeFantasia.Contains(sConsulta)).ToList();
    return View(consulta);
}



@using (Html.BeginForm())
{
 <p>Digite o nome/fantasia</p>
 <input placeholder="Digite o Nome/Fantasia" type="text" name="sConsulta" id="sConsulta"  />
 <div><button type="submit">Consultar</button></div>   
}

Browser other questions tagged

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