Hi,
I am using asyncupload for storing files into database.
I have 2 grids and a upload control and a save to database button. The selection of a row from 1st grid selects rows from 2nd grid. After this, a file is uploaded using asyncupload. Now by clicking the submit button I want to save the grid selections and the file to database.
I have attached a PostbackTriggers property to asyncupload control because when i upload a file and change the selection in first grid the file is gone because of postback. If i remove PostbackTriggers property UploadedFiles count is not zero.
The UploadedFiles of asyncupload is always returning 0 files when i use PostbackTriggers.
I have attached an image to describe the controls.
I am using asyncupload for storing files into database.
I have 2 grids and a upload control and a save to database button. The selection of a row from 1st grid selects rows from 2nd grid. After this, a file is uploaded using asyncupload. Now by clicking the submit button I want to save the grid selections and the file to database.
I have attached a PostbackTriggers property to asyncupload control because when i upload a file and change the selection in first grid the file is gone because of postback. If i remove PostbackTriggers property UploadedFiles count is not zero.
The UploadedFiles of asyncupload is always returning 0 files when i use PostbackTriggers.
I have attached an image to describe the controls.
5 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 25 Nov 2013, 03:11 AM
Hi TelDev,
Please have a look into the following code snippet to get the count of UploadedFiles of RadAsyncUpload.
ASPX:
C#:
Thanks,
Shinu.
Please have a look into the following code snippet to get the count of UploadedFiles of RadAsyncUpload.
ASPX:
<
telerik:RadAsyncUpload
ID
=
"RadAsyncUpload1"
runat
=
"server"
PostbackTriggers
=
"RadButton1"
OnFileUploaded
=
"RadAsyncUpload1_FileUploaded"
>
</
telerik:RadAsyncUpload
>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Save UploadedFile"
>
</
telerik:RadButton
>
<
telerik:RadButton
ID
=
"RadButton2"
runat
=
"server"
Text
=
"Page PostBack"
>
</
telerik:RadButton
>
C#:
protected
void
RadAsyncUpload1_FileUploaded(
object
sender, Telerik.Web.UI.FileUploadedEventArgs e)
{
// when RadButton1 Click is happening this event will execute
int
count = RadAsyncUpload1.UploadedFiles.Count;
}
Thanks,
Shinu.
0

TelDev
Top achievements
Rank 1
answered on 25 Nov 2013, 08:09 AM
Thanks Shinu for the reply,
I need UploadedFiles in some button event, but not in
As you see in my attached image, I need the UploadedFiles count and the file in "Apply" button click.
Thanks
TelDev
I need UploadedFiles in some button event, but not in
RadAsyncUpload1_FileUploaded
.As you see in my attached image, I need the UploadedFiles count and the file in "Apply" button click.
Thanks
TelDev
0

Shinu
Top achievements
Rank 2
answered on 26 Nov 2013, 02:46 AM
Hi TelDev,
Please have a look into the following code snippet to get the count and file name of the uploaded file in RadButton OnClick event.
ASPX:
C#:
Thanks,
Shinu.
Please have a look into the following code snippet to get the count and file name of the uploaded file in RadButton OnClick event.
ASPX:
<
telerik:RadAsyncUpload
ID
=
"RadAsyncUpload1"
runat
=
"server"
PostbackTriggers
=
"RadButton1"
>
</
telerik:RadAsyncUpload
>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Apply"
OnClick
=
"RadButton1_Click"
>
</
telerik:RadButton
>
<
telerik:RadButton
ID
=
"RadButton2"
runat
=
"server"
Text
=
"Page PostBack"
>
</
telerik:RadButton
>
C#:
protected
void
RadButton1_Click(
object
sender, EventArgs e)
{
string
[] uplodedfile =
new
string
[20];
//count of the uploaded file
int
count = RadAsyncUpload1.UploadedFiles.Count;
int
i=0;
foreach
(UploadedFile file
in
RadAsyncUpload1.UploadedFiles)
{
//filename of the uploaded file
uplodedfile[i] = file.FileName;
i++;
}
}
Thanks,
Shinu.
0

TelDev
Top achievements
Rank 1
answered on 26 Nov 2013, 09:04 AM
Thank you again Shinu,
My case is bit different. If you see the attached image I have 2 grids and a upload control. I need a postbacktrigger for grid1 and also apply button.
Can I use 2 controls for postbacktriggers property?
I have found the documentation, it seems I can set multiple controls.
http://www.telerik.com/help/aspnet-ajax/asyncupload-persist-uploaded-files.html
Thanks
TelDev
My case is bit different. If you see the attached image I have 2 grids and a upload control. I need a postbacktrigger for grid1 and also apply button.
Can I use 2 controls for postbacktriggers property?
I have found the documentation, it seems I can set multiple controls.
http://www.telerik.com/help/aspnet-ajax/asyncupload-persist-uploaded-files.html
Thanks
TelDev
0

Shinu
Top achievements
Rank 2
answered on 27 Nov 2013, 07:11 AM
Hi TelDev,
It is possible to set more than one control in the PostbackTriggers property of RadAsyncUpload. Please have a look into the following code snippet to set two controls in PostbackTriggers property.
ASPX:
Thanks,
Shinu.
It is possible to set more than one control in the PostbackTriggers property of RadAsyncUpload. Please have a look into the following code snippet to set two controls in PostbackTriggers property.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
AllowPaging
=
"true"
runat
=
"server"
DataSourceID
=
"SqlDataSource1"
AutoGenerateColumns
=
"true"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"OrderID"
DataField
=
"OrderID"
UniqueName
=
"OrderID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"CustomerID"
DataField
=
"CustomerID"
UniqueName
=
"CustomerID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"ShipName"
DataField
=
"ShipName"
UniqueName
=
"ShipName"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Apply"
OnClick
=
"RadButton1_Click"
>
</
telerik:RadButton
>
<
telerik:RadAsyncUpload
ID
=
"RadAsyncUpload1"
runat
=
"server"
PostbackTriggers
=
"RadButton1,RadGrid1"
>
</
telerik:RadAsyncUpload
>
Thanks,
Shinu.