I have a dropdownlist that looks like this:
@Html.DropDownListFor(
x => x.At开发者_JAVA百科tribute.AttributeID,
new SelectList(Model.Attributes, "AttributeID", "Name")
)
In my controller I've tried parameters like attributeId and attribute_attributeId, this is my code:
[HttpPost]
public ActionResult Index(int productId, int attributeId)
(Btw, I'm also receiving the ProductID which is in the query string)
The output of my ddl is ... id="Attribute_AttributeID" name="Attribute.AttributeID" ...
I've tried this also:
@Html.DropDownListFor(
x => x.Attribute.AttributeID,
new SelectList(Model.Attributes, "AttributeID", "Name"),
null,
new { id = "attributeId", name = "attributeId" }
)
But then the id just changes and not the both...
So my question is how can I be able to reach the dll without having to write something like x => x.SelectedAttributeID in the ddl.
[HttpPost]
public ActionResult Index(Attribute attribute)
{
// attribute will have the attributeId property
}
精彩评论