I am using mvc4 and have a telerik control grid with editing mode enabled. The edit mode is “PopUp” , that means that on click of the edit button, an overlay should appear with some of the fields populated in textboxes and some in labels.
The issue is that the field values are not rendered in labels. Field values are rendered in textboxes for editing which is fine.
View Model
namespace Admin.Models
{
public class ViewModel
{
public int Id{ get; set; }
[DataType(DataType.Text)]
public string Name { get; set; }
}
}
.cshtml file
@model Admin.Models.ViewModel
<div>
<div class="editor-label">
@Html.LabelFor(model => model.Id)
</div>
<div class="editor-field">
@Model.Id **Does not work,always return 0, should return value 1,2,...**
@Html.DisplayFor(model => model.Id) **Does not work,always return 0, should return value 1,2,...**
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
</div>
</div>
Controller code
[GridAction]
public ActionResult Index()
{
IList<ViewModel> viewModels = GetModelItems();
return View(new GridModel
{
Data = viewModels
});
}
Teleric don’t seem to support DisplayFor in editing templates.
In this froum thread they confirm it http://www.telerik.com/community/forums/aspnet-mvc/grid/clajax-databinding-client-editing.aspx#1906385