我没有与帮助者合作的经验,因此我不大愿意使用手法。
My requirement is simple and all I need is optgroup functionality in DropDownListFor
extension method. While searching, I came across this Answer and have copied this as it is in a file named MyExtensionClass.cs.
但是,我不知道如何使用这一方法,也没有说其中界定的推广方法。 请告诉我,我怎么能够用我的名单来做到这一点。
Right now, following is the controller code for a selectlist for which i want to use the extension methods.
ViewBag.ParentCategoryId = new SelectList(db.Categories, "Id", "Name");
这也是我的看法。
@Html.DropDownListFor(model => model.Product.CategoryId,
(IEnumerable<SelectListItem>)ViewBag.CategoryId, "---Choose Category---",
new { @class = "required" })
请帮助我把这一方法升级为选择小组的推广方法。