【发布时间】:2014-05-17 03:06:54
【问题描述】:
我知道有很多这样的话题,但我找不到答案。
在代码中:
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>TabelaModel</legend>
@Html.HiddenFor(model => model.ID)
<div class="editor-label">
@Html.LabelFor(model => model.Druzyna)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Druzyna)
@Html.ValidationMessageFor(model => model.Druzyna);
</div>
<div class="editor-label">
@Html.LabelFor(model => model.LiczbaMeczy)
</div>
<div class="editor-field">
@Html.TextBox(model => model.LiczbaMeczy)
@Html.ValidationMessageFor(model => model.LiczbaMeczy)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.LiczbaGoliStrzelonych)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.LiczbaGoliStrzelonych)
@Html.ValidationMessageFor(model => model.LiczbaGoliStrzelonych)
</div>
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
}
编译器正在抛出异常:
@Html.TextBox(model => model.LiczbaMeczy)
我已将 System.Linq、System.Data.Entity 放入模型、视图、控制器中,但仍然没有。当我将@Html.TextBox 替换为@Html.EditorFor 时它正在工作,但我真的很想避免这种情况。我的模型课:
namespace GridViewTest.Models
{
public class TabelaModel
{
public int ID { get; set; }
public string Druzyna { get; set; }
[Required (ErrorMessage="*")]
public string LiczbaMeczy { get; set; }
[Required(ErrorMessage = "*")]
public int LiczbaGoliStrzelonych { get; set; }
}
}
你能帮帮我吗?
【问题讨论】:
标签: asp.net-mvc lambda