0
code For It
され持っています私は、カテゴリのドロップダウン enter image description hereは私がに応じてカテゴリの製品sholud負荷を選択したときにだけ必要がある2つのドロップダウンカテゴリと製品を、私は二つのDropdownlistsカテゴリーの一つと私はAAのITMフォームのドロップダウンカテゴリにその後、製品のドロップダウンリストを選択する第二の製品を作っ
public partial class Product
{
public int ProductID { get; set; }
public int CategoryID { get; set; }
public string ProductName { get; set; }
}
}
public partial class Category
{
public int CategoryID { get; set; }
public string CategoryName { get; set; }
public virtual ICollection<Product> Products { get; set; }
}
public ActionResult Create()
{
ViewBag.vbCategoryList = new SelectList(db.Categories.Select(x => new { Value = x.CategoryID, Text = x.CategoryName}), "Value", "Text");
ViewBag.vbProductList = new SelectList(db.Products.Select(x => new { Value = x.ProductID, Text = x.ProductName }), "Value", "Text");
return View();
}
<table class="table">
<tr>
<td>Category</td>
<td>Product</td>
<td>Quantity</td>
<td>Rate</td>
<td> </td>
</tr>
<div id="Tbody1">
<tr class="mycontainer" id="mainrow">
<td>
@Html.DropDownListFor(model => model.CategoryID, (SelectList)ViewBag.vbCategoryList, "Select One", htmlAttributes: new { @class = "form-control" })
</td>
<td>`
@Html.DropDownListFor(model => model.ProductID, (SelectList)ViewBag.vbProductList, "Select One", htmlAttributes: new { @class = "form-control" })
</td>
<td></td>
<td>
<input type="text" id="rate" class="rate form-control" />
</td>
<td>
<input type="button" id="AddMore" style="width:80px" value="AddMore" class="btn btn-success /">
</td>
</tr>
</div>
から選択したカテゴリに応じて製品を表示すべきである[ここに画像の説明を入力します] [2]
を与えたいとhttps://stackoverflow.com/questions/12258839/populate-dropdown-list-based-on-another-dropdown-list ..Must顔をして、それを変更することができますこれで – Dhawal