本文介绍了淘汰赛的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到错误Mobjlineitem未定义
< tbody data-bind =foreach:MobjLineitems>
< tr>
< td>
< input data-bind =@ Html.DataBinding(m => m.MobjLineitems,it => it.MobjLineitem.productid)type =textvalue =/>
< / td>
< td class =number>
< input data-bind =@ Html.DataBinding(m => m.MobjLineitems,it => it.MobjLineitem.rate)type =textvalue =class =number pure -input-2-3/>
< / td>
< td class =number>
< input data-bind =@ Html.DataBinding(m => m.MobjLineitems,it => it.MobjLineitem.quantity)type =textvalue =class =number pure -input-2-3/>
< / td>
< td class =number>
< input data-bind =value:Valuereadonly =readonlytype =textvalue =class =number pure-input-2-3/>
< / td>
< td>
< input type =buttonclass =pure-buttondata-bind =click:$ parent.delItemvalue =delete/>
< / td>
< / tr>
< / tbody>
我使用如下助手
public static string DataBinding< TModel,U,V>(此 HtmlHelper< TModel>助手,表达式< Func< TModel,IEnumerable >> listExpr,
表达式< Func< U,V>> memberExpr)
{
var meta = ModelMetadata.FromLambdaExpression(listExpr,helper.ViewData);
var listName = meta.PropertyName;
string itemName = GetFullPropertyName(memberExpr);
return string .Format( value:{1},attr:{{id:'{0} _'+ $ index()+'__ {1}',name:' {0} ['+ $ index()+']。{1}'}},listName,itemName);
}
itemName是有价值Mobjlineitem.productid
当它刚刚产生没有错误时
任何解决方案?
解决方案
iam getting error Mobjlineitem not defined
<tbody data-bind="foreach: MobjLineitems"> <tr> <td> <input data-bind="@Html.DataBinding(m => m.MobjLineitems, it => it.MobjLineitem.productid)" type="text" value="" /> </td> <td class="number"> <input data-bind="@Html.DataBinding(m => m.MobjLineitems, it => it.MobjLineitem.rate)" type="text" value="" class="number pure-input-2-3" /> </td> <td class="number"> <input data-bind="@Html.DataBinding(m => m.MobjLineitems, it => it.MobjLineitem.quantity)" type="text" value="" class="number pure-input-2-3" /> </td> <td class="number"> <input data-bind="value: Value" readonly="readonly" type="text" value="" class="number pure-input-2-3" /> </td> <td> <input type="button" class="pure-button" data-bind="click: $parent.delItem" value="delete"/> </td> </tr> </tbody>
Iam using helper as below
public static string DataBinding<TModel, U, V>(this HtmlHelper<TModel> helper, Expression<Func<TModel, IEnumerable>> listExpr, Expression<Func<U, V>> memberExpr) { var meta = ModelMetadata.FromLambdaExpression(listExpr, helper.ViewData); var listName = meta.PropertyName; string itemName = GetFullPropertyName(memberExpr); return string.Format("value: {1}, attr: {{ id : '{0}_' + $index() + '__{1}', name: '{0}[' + $index() + '].{1}' }}",listName, itemName); }
itemName is having value Mobjlineitem.productid
when its just productid there is no error
Any solution?
解决方案
这篇关于淘汰赛的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!