Radasyncupload in Itemtemplate (not in edittemplate)

6 posts, 1 answers
  1. Frank
    Frank avatar
    16 posts
    Member since:
    Oct 2011

    Posted 27 Mar 2013 Link to this post

    Have been searching for a while.  Not sure if is possible.  I know how to access radasyncupload in edittemplate, but what about in itemtemplate? 

    Is it possible to

     

    <telerik:GridTemplateColumn DataField="xx" HeaderText="xx" UniqueName="xx">

        <ItemTemplate>

            <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" MaxFileInputsCount="1" />

        </ItemTemplate>

     

    </telerik:GridTemplateColumn>

    So that when the grid displays 10 rows, it will have 10 asyncupload control on the screen.  Then the user can select 10 different files into the 10 asyncupload control.  And with a button press (outside of the grid) which will cause post back.  And then I would like to somehow have access to the "fileuploaded" event fires and then able to use the .saveas method to save all 10 file (with manipulated filename) to a folder. 

    I tried to to add onclientFileUploaded="FileUploaded"  and then in the code behind

    Protected sub FileUploaded(blah)

    But when ran, it said it FileUploaded function not exist.  I assume that is because the control is in itemtemplate, therefore it can not access it.

    Any idea?  Or is this not possible?

    Thx!

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 28 Mar 2013 Link to this post

    Hi,

    Try the following code to achieve your scenario.
    c#:
    protected void Button1_Click(object sender, EventArgs e)
    {
            foreach (GridDataItem item in RadGrid1.Items)
            {
                RadAsyncUpload upload = (RadAsyncUpload)item.FindControl("RadAsyncUpload1");
                upload.OnClientFileUploaded = "OnClientFileUploaded";
            }
    }

    Thanks,
    Princy
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Frank
    Frank avatar
    16 posts
    Member since:
    Oct 2011

    Posted 29 Mar 2013 Link to this post

    Hello Princy,

    Thank you for your help.  It seems to be almost working, but I need to fire the .saveas method to save the uploaded filename into a different one.  The main problem is that once the control is in the "itemtemplate" I don't know how to wireup to the code behind (server side event).  Obviously once is in "itemtemplate" you no longer get the object in the dropdown items on the code behind. 

    And by using your method, once button clicked, it posted back already and the file has been copied to the target folder and the temp file has been wiped out.  Therefore, it is too late to call the .saveas method, as the method no longer can find the temp files. 

    I need somehow be able to "code for" the "RadAsyncUpload1_FileUploaded() Handles for ??"  event for the control inside of the itemtemplate, one by one so that I can do .saveas method for each file uploaded. 

    I can not find the clientside method for .saveas so I guess that is not avaliable.

    Any more idea? 

    thanks in advance!

    Frank
  5. Frank
    Frank avatar
    16 posts
    Member since:
    Oct 2011

    Posted 29 Mar 2013 Link to this post

    Ok, so I figure I can put the .saveas code in the Page_load event.  Can you think a better place to put it other then page_load?
  6. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 01 Apr 2013 Link to this post

    Hi,

    Try the following code.
    C#:
    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
      if (e.Item is GridDataItem)
      {
        GridDataItem item = (GridDataItem)e.Item;
        RadAsyncUpload upload = (RadAsyncUpload)item.FindControl("RadAsyncUpload1");
        upload.FileUploaded += new FileUploadedEventHandler(upload_FileUploaded);
      }
    }
    void upload_FileUploaded(object sender, FileUploadedEventArgs e)
    {
    }

    Thanks,
    Princy
  7. Frank
    Frank avatar
    16 posts
    Member since:
    Oct 2011

    Posted 04 Apr 2013 Link to this post

    Thank you!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017