This question is locked. New answers and comments are not allowed.
Hi,
I need to have a grid where for each row I should have an upload control.
The upload works fine for the first upload control, but when I press on the second, after I select the files, nothing happens.
I figured out that this is due to the fact that all the controls get generated with the same name and id.
If I change the name of the upload control from .Name("attachments") into .Name("attachments" + counter++), when the save method gets invoked, the attachments is set to null, so I cannot retrieve the files. If I create a Save method for each row, with the first parameter named exactly as each upload control, it works, but I do not have a fixed max number of rows, so this is not a solution.
How shall I implement it to get it working?
Cheers,
Sorina
I need to have a grid where for each row I should have an upload control.
The code looks like:
columns.Template(o =>
{%>
<%=Html.Telerik().Upload()
.AssetKey(o.Course.Aktivitetskode)
.Name("attachments")
.Multiple(true)
.Localizable("Da")
.HtmlAttributes(new { @class = "myCustomClass"})
.Async(async => async
.Save("Save", "Enrollment", new {folderPath = o.Documentation.FolderPath, courseActivityCode=o.Course.Aktivitetskode })
.Remove("Remove", "Enrollment", new { folderPath = o.Documentation.FolderPath })
.AutoUpload(true)
)%>
<% });
The Save method signature looks like:
public ActionResult Save(IEnumerable<HttpPostedFileBase> attachments, string folderPath, string courseActivityCode)
The upload works fine for the first upload control, but when I press on the second, after I select the files, nothing happens.
I figured out that this is due to the fact that all the controls get generated with the same name and id.
If I change the name of the upload control from .Name("attachments") into .Name("attachments" + counter++), when the save method gets invoked, the attachments is set to null, so I cannot retrieve the files. If I create a Save method for each row, with the first parameter named exactly as each upload control, it works, but I do not have a fixed max number of rows, so this is not a solution.
How shall I implement it to get it working?
Cheers,
Sorina