This is a migrated thread and some comments may be shown as answers.

RadAsyncUpload issues inside EditFormTemplate

1 Answer 61 Views
Grid
This is a migrated thread and some comments may be shown as answers.
devali
Top achievements
Rank 1
devali asked on 12 Sep 2016, 04:17 PM

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
}

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 15 Sep 2016, 12:14 PM
Hi Devali,

Once you cancel the update/insert by setting e.Canceled to true, the initial file will be remove and the edit form will be kept open. When you select another file and try to update the item again, the new file will be available in the UploadedFiles collection. I have tested this locally with simple RadGrid and EditFormTemplate and everything works correctly.

If the issue persists, please open a regular support ticket and attach the markup and the code-behind of you page, so we can examine it locally. Meanwhile you can inspect your browser's console for any JavaScript errors, temporary disable AJAX (if it is enabled) and debug your code to see if the UploadedFiles collection is empty the second time.


Best Regards,
Konstantin Dikov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
devali
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or