Johny Bravo
asked on
Asp.Net MVC dropdown
Hello Experts,
I am learning MVC so please help me.
I am using Entity Framework for CRUD operation.
When I generate Controller/ View for Products, it creates Index/ Edit/ Details/ Delete view.
What I need is, in Create View, it creates only one dropdown for "SubCategory", instead I want to have "Category" Dropdown
and after its selection "SubCategory" dropdown.
Your help is appreciated. Thanks
dbpng.png
I am learning MVC so please help me.
I am using Entity Framework for CRUD operation.
When I generate Controller/ View for Products, it creates Index/ Edit/ Details/ Delete view.
What I need is, in Create View, it creates only one dropdown for "SubCategory", instead I want to have "Category" Dropdown
and after its selection "SubCategory" dropdown.
Your help is appreciated. Thanks
dbpng.png
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok now what I've done,
<div class="editor-label">
@Html.LabelFor(model => model.CategoryId, "Category")
</div>
<div class="editor-field">
@Html.DropDownList("Catego ryId", String.Empty)
@Html.ValidationMessageFor (model => model.CategoryId)
</div>
and in controller,
ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName");
so it creates a Category dropdown, but I need subcategory dropdown to be filled based on the selection of Category.
>>Moving from Asp.Net to MVC is a bit difficult :)
>>As in Asp.Net, we could have AutoPostBack="true" and fill the Subcategory ddl.
<div class="editor-label">
@Html.LabelFor(model => model.CategoryId, "Category")
</div>
<div class="editor-field">
@Html.DropDownList("Catego
@Html.ValidationMessageFor
</div>
and in controller,
ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName");
so it creates a Category dropdown, but I need subcategory dropdown to be filled based on the selection of Category.
>>Moving from Asp.Net to MVC is a bit difficult :)
>>As in Asp.Net, we could have AutoPostBack="true" and fill the Subcategory ddl.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Please check
Create.txt
ProductsController.txt
Product.txt