I am using a Telerik MVC grid to let the users manage the reports in the system. I built an EditorTemplate with some fields in it and with an uploader from Telerik.
I want to pass the ReportId to the uploader method so that it knows the report record to which the file belongs.
@model MyMvcApp.Models.ReportModel
@Html.DisplayFor(t => t.ReportID)
@Html.HiddenFor(t=> t.ReportID)
@(Html.Telerik().Upload()
.Name("attachments")
.Multiple(false)
.Async(async => async.Save("Save", "Report",
new { Id = Model.ReportID })
.AutoUpload(true)
))
However, the Model.RaportId returns an empty GUID.
Also, the @Html.DisplayFor(t => t.ReportID) doesn't work properly.
But the @Html.HiddenFor(t=> t.ReportID) works just fine when I inspect the page.
I know that Telerik is building a dummy model when creating the editor template. But what can be done?
- Use javascript to populate a ViewBag variable and use that in the save method?
- Call the model in a different way?
All in all, I have now changed to using separate views for create/update, but I'd like to build this into the grid. The experience would be better.