I'm working with MVC 4.0 and I'd need a page with 3 drop downlists and a table.
When an item is selected from DDL1 (e.g. Users) then DDL2 (e.g. Accounts) is populated. When an item is selected from DDL2 (Accounts) then DDL3 (e.g. Cards) is populated. When an item is selected from DDL3 then the table has to display a list of objects e.g. Transactions (with Amount, etc).
So I created a TransactionManagementController and created an Index Action which loads the Users and displays them initially.
public ActionResult Index()
{
var vm = new VmTransactionManagement
{
Users = db.Users.ToList()
};
return View(vm);
}
<th>User:</th>
<td>@Html.DropDownListFor(m => m.SelectedUser,
Model.UsersSelectList,
"-- Select One --")</td>
Also, I created a view model for this controller: VmTransactionManagement which contains some other objects needed.
So, now how would I code so that when DDL1 is selected (userId is passed), then DDL2 gets populated?
Should I be creating a new action/view and calling it by Ajax?
If I create a new Action, then I'll have to create a new View which changes the previously selected values.