Answer the question
In order to leave comments, you need to log in
How to link two @html.dropdownlistfor?
Good evening!
When building a project in asp.net mvc, I got to the point where I need to link two dropdownlists, I build them this way:
public class HomeController : Controller
{
Database1dbContext _db = new Database1dbContext();
public ActionResult Index()
{
var p = from m in _db.Teams select m;
ViewBag.ddl = new SelectList(p, "Id", "Name");
var k = from h in _db.Players where h.TeamId == 1 select h;
ViewBag.ddl2 = new SelectList(k, "Id", "Name");
returnView();
}
}
Please tell me how can I specify the value from the table instead of 1 (where h.TeamId == 1) in this condition???
Answer the question
In order to leave comments, you need to log in
Good afternoon!
First, I don't understand the question.
Please tell me how can I specify the value from the table instead of 1 (where h.TeamId == 1) in this condition???
How to link two @html.dropdownlistfor(if I understood it correctly), then on the server side (ie in C#) you will not link multiple dropdown lists. If you need that when you select any element from list #1 (let it be
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question