0

我在将值返回到我的剑道网格和字段视图时遇到问题。

早些时候,我的局部视图中只有剑道网格,因此我使用下面的代码来返回网格的值:

public virtual ActionResult GetValues(long Id1, [DataSourceRequest]DataSourceRequest request)
{
   return Json(ViewModel.List<Another_View_Model>.ToDataSourceResult(request));
}

我的视图模型结构如下

ViewModel 
{
    public long Id { get; set; }
    public List<Another_View_Model> Another_View_Model { get; set; }
}

但是现在,我将剑道文本框、复选框添加到同一个局部视图中,并且希望在返回网格值的同时也将服务器值返回到这些字段。

我的视图模型结构如下

ViewModel 
{
    public long Id { get; set; }
    public List<Another_View_Model> Another_View_Model { get; set; }
    public string textboxField { get; set; }
}

在我的控制器中,我正在进行以下更改,但我的文本框字段值没有返回到视图。

public virtual PartialViewResult GetValues(long Id1)
{
   return PartialView("_PartialView", ViewModel);
}

谁能指出我做错的地方,或者有更好的方法在同一模型中同时返回网格和剑道元素的结果。

我的视图结构如下:

@model ViewModel

  @(Html.Kendo().TextBoxFor(p => p.textboxField)
                              .Name("TextBox")
                    )

 @(Html.Kendo().Grid<Another_View_Model>()
                         .Name("KendoGrid")

对此的任何帮助表示赞赏。提前致谢!!

4

1 回答 1

0

使用其中一个TextBoxFor(p => p.PropertyName)TextBox().Name("PropertyName")不要同时使用。name 属性将覆盖 TextBoxFor。因此,在您的示例中,您的 Kendo 文本框实际上是绑定到一个名为的属性TextBox,而不是textboxField像您期望的那样。

反之亦然,如果您发布表单,模型textboxField将为空,而如果您有一个名为的字符串参数TextBox,它将使用文本框的值填充

于 2014-04-03T14:54:22.847 回答