Asp.net mvc 无法将lambda表达式转换为类型';字符串';因为它不是委托类型的MVC
我知道有很多像这样的话题,但我找不到答案 代码:Asp.net mvc 无法将lambda表达式转换为类型';字符串';因为它不是委托类型的MVC,asp.net-mvc,lambda,Asp.net Mvc,Lambda,我知道有很多像这样的话题,但我找不到答案 代码: @using (Html.BeginForm()) { @Html.ValidationSummary(true) <fieldset> <legend>TabelaModel</legend> @Html.HiddenFor(model => model.ID) <div class="editor-label"> @Html.LabelFor(
@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>
我已经在模型、视图和控制器中放置了一个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; }
}
}
您能帮我吗?您需要使用
TextBoxFor
(而不是TextBox
):
这将采用lambda表达式。谢谢,它现在可以工作了!。我将在10分钟内接受答案:)。我确信@Html.TextBox会很好的解决这个问题。。
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; }
}
}
@Html.TextBoxFor(model => model.LiczbaMeczy)