1
这是我对我的模型型号返回空值
public class ManufacturerModel
{
public int ProductTYpeId { get; set; }
public int Id { get; set; }
public string Name { get; set; }
public List<SelectListItem> manf { get; set; }
public Manufacturer manufacturer { get; set; }
}
代码这是我在CSHTML文件
@using (Html.BeginForm("addmanufacturer", "Admin", FormMethod.Post, new { id = "formPageID" }))
{
<div class="row">
<label>Select Existing Manufacturer<span style="color: Red">*</span>:</label>
<div class="formRight">
@Html.DropDownList("Id", Model.manf)
</div>
</div>
<div class="row">
<label>Manufacturer Name<span style="color: Red">*</span>:</label>
<div class="formRight">
@Html.TextBoxFor(m => m.manufacturer.name)
@Html.ValidationMessageFor(m => m.manufacturer.name)
</div>
</div>
}
我张贴这种形式,当我试图获取从值码manfacurer ie - ManufacturerModel manufacturer = new ManufacturerModel(); 使用模型对象所有的值都是空值。
在文本框中如果我用m => m.Name替换它,那么我能够得到适当的Name值。 任何一个可以提出什么问题
我正在使用manf来绑定下拉菜单。如果万一我回来后的形式和它是否返回值将变为空白,我需要补充的价值..
public ActionResult addmanufacturer(string id)
{
if (id == null)
id = "0";
ManufacturerModel manufacturer = new ManufacturerModel();
manufacturer.ProductTYpeId = Convert.ToInt32(id);
manufacturer.manf = GetManf();
manufacturer.Id = -1;
return View(manufacturer);
}
请加1或u试图从你的问题 – 2013-02-27 20:12:25
操作方法的所有版本,你有2名属性 - 一个你的模型和其他的制造商 - 要使用哪些呢? – codingbiz 2013-02-27 20:14:34
我想使用制造商型号中的那个。另一个名称仅用于测试目的。 – 2013-02-27 20:40:56