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

Radasyncupload in Itemtemplate (not in edittemplate)

5 Answers 86 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 28 Mar 2013, 01:42 AM
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!

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 Mar 2013, 10:43 AM
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
0
Frank
Top achievements
Rank 1
answered on 29 Mar 2013, 01:49 PM
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
0
Frank
Top achievements
Rank 1
answered on 29 Mar 2013, 02:20 PM
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?
0
Accepted
Princy
Top achievements
Rank 2
answered on 01 Apr 2013, 07:38 AM
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
0
Frank
Top achievements
Rank 1
answered on 04 Apr 2013, 02:10 PM
Thank you!
Tags
AsyncUpload
Asked by
Frank
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Frank
Top achievements
Rank 1
Share this question
or