我有一个下面的模型
public class category
{
[Key]
public long category_id { get; set; }
public string category_desc { get; set; }
public long? client_id { get; set; }
public long? display_sno { get; set; }
}
控制器将模型传递给查看
public ActionResult category(long? client_id)
{
var category_type = db.category.Where(m => m.client_id == null).ToList();
if(client_id == 10)
{
category_type = db.category.Where(m => m.client_id == client_id).ToList();
}
return View(category_type);
}
在视图中填充单选按钮
@foreach (var item in Model)
{
@Html.DisplayFor(modelItem => item.display_sno)<text>.</text>
@Html.RadioButtonFor(modelItem => item.category_id, item.category_id, new { id=item.category_id})@item.category_desc
}
发布方法
public ActionResult Category(category g)
{
}
In post 方法g
将作为null
. 我在这里缺少什么?