我有一个表格,我想发布,以确保页面刷新数据(而不是ajax方式)刷新。问题是我只想发布记录的Id并将其提取到控制器方法中。我发现表单发布了一切(我可能无法解决这个问题,因为相同的表单用于更新)。但我希望能够将变量弹出到控制器方法的参数中,而不是从FormCollection中提取。我已经尝试了下面的各种参数,但都传递null。任何想法是什么问题?Mvc Controller方法中的FormsCollection - 任何其他访问方式?
我在我的控制器方法如下:
public ActionResult Delete(FormCollection collection)
{
var idToDelete = collection["Current.CommissionStructureId"].ToInt32();
}
// tried the following but none of them bind
public ActionResult Delete(int? Current_CommissionStructureId, int? CommissionStructureId, int? Id, int? id)
{
// none of the above are binding (set to null)
}
我不知道怎么做,但什么问题做出单独的表格/链接删除?作为一个简单的解决方案,您可以将隐藏字段添加到名为CommissionStructureId的表单中。 –