RadAsyncUpload issues inside EditFormTemplate

2 posts, 0 answers
  1. devali
    devali avatar
    1 posts
    Member since:
    Apr 2013

    Posted 12 Sep Link to this post

    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
    }

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 15 Sep Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top