So I have a hierarchical RadGrid with 1 master table and 1 detail table.
The detail table has the property
<EditFormSettings EditFormType="Template">The TemplateForm has 1 TextBox and 1 RadAsyncTable and the submit button (insert, update).
Now when I choose a file to upload and hit "insert" the file is uploaded and everything works correctly.
The problem is that when the file exists, I want to display an error message : "the file already exists". So I have a method to verify if the file exists. If this is the case, I want to keep the EditForm opened and display the error message. But when I choose another file that doesn't exist and hit submit again, it looks like the RadAsyncUpload loses its value and the file is gone.
Here is my code:
try { UploadedFile file = btn.UploadedFiles[0]; bool exists = BDD.CheckIfDocumentExists(fileName); if (!exists) file.SaveAs(Path.Combine(targetFolder, fileName));} catch (Exception ex) { // log the error}if (exists) { GridEditableItem item = (GridEditableItem) e.Item; Label RadTextBox1 = (Label) item.FindControl("lbl_detailerror"); RadTextBox1.Text = "the file already exists"; e.Canceled = true;} else { // insert the file in db}