5
Answers

Multiple File Upload in Gridview for each row

Dear all,
 
My Requirement is - 
I have to upload multiple files for each row in GridView.
 
I have taken reference from -
http://www.aspsnippets.com/Articles/Implement-Uploadify-jQuery-Plugin-in-ASPNet.aspx
 
My aspx page is -
<head runat="server">

<link href="App_Themes/JQuery_MultipleFilesUploadAndDownload/uploadify.css" rel="stylesheet" />
</head>
<body>
<script type="text/javascript" src="App_Themes/JQuery_MultipleFilesUploadAndDownload/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="App_Themes/JQuery_MultipleFilesUploadAndDownload/jquery.uploadify.js"></script>
<form id="form1" runat="server"> <div align="center">
<table border="0" cellpadding="0", cellspacing="2">
<tr>
<td><strong>File Upload</strong></td>
<td>
<asp:GridView ID="grdData" runat="server" OnRowCreated="grdUpdateAssetStatus_RowCreated" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:FileUpload ID="fileupload1" runat="server"/>
<script type = "text/javascript">
$(window).load(
function () {
$("[id*=fileupload1]").fileUpload({
'uploader': 'App_Themes/JQuery_MultipleFilesUploadAndDownload/uploader.swf',
'cancelImg': 'App_Themes/JQuery_MultipleFilesUploadAndDownload/cancel.png',
'buttonText': 'Browse Files',
'script': 'UpdateAssetStatusFileUploadHandler.ashx',
'folder': 'uploads',
'fileDesc': 'Image Files',
'fileExt': '*.jpg;*.jpeg;*.gif;*.png',
'multi': true,
'auto': true
});} );
</script>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle Height="50px" BackColor=" #000066" ForeColor="White" />
</asp:GridView>
</td>
</tr>
</table>
</div>
</form>
</body>
-----
Issue-
Line - $("[id*=fileupload1]").fileUpload({
$("[id*=fileupload1]").fileUpload({ - Output - 3 Browser Buttons
$("#<%=fileupload1.ClientID %>").fileUpload({ - Error - The element does not exist in the current context 
--------
Please correct me where I am going wrong.
Answers (5)
0
Riddhi Valecha

Riddhi Valecha

NA 3.1k 186.5k 8y
Hi all..
 
I have checked all the links..
 
I have made multiple file upload by using jquery uploadify plugin.
 
GridView Design -
 
------
For First Record - I need to upload 3 image files.
For Second Record - I need to upload 2 image files.
 
Result in database -

ID
  RecordID File
 1 1 img1.jpg
 2 1 img2.jpg
 31 img3.jpg
 4 2 img4.jpg
 5 2 img5.jpg
 
How do I make a loop ?
 
Foreach(gridviewrow row in grdData.rows)
{
 String rowid = row.cells[2].text.trim();
 FileUpload fup = (FileUpload)row.FindControl("DataFileUpload") as FileUpload;
 
In HttpPostedFiles ; Total count = 5 files I am getting.
 
How to go further .. Please guide...
}
--
How to find out - that in each row - how many files the user have selected in gridview ?
 
Please guide... It is a bit urgent and important...
 
Thanks a ton in advance .....
0
Riddhi Valecha

Riddhi Valecha

NA 3.1k 186.5k 8y
Hi all..
 
In GridView, I have 3 columns as below -
 IDName
 
 1 A Browse
 2 B Browse
 3 C  Browse
 4 D  Browse
 
For record-1 (ID = 1), I have to upload 2 image files (img1.jpg and img2.jpg).
 
In database, I want to insert the following -
 
ID  Name File
 1 A img1.jpg
 2 A img2.jpg
 
 Similarly, for record - 2(ID=2), I have to upload 3 image files. Hence , 3 records for this are to be inserted.
 
How to I do this logic ? Please guide..
0
Abhishek Singh

Abhishek Singh

NA 5.3k 1.1m 8y
Hi,
 
Try this link below..
 
https://vinayakshrestha.wordpress.com/2008/02/19/aspnet-gridview-multiple-files-upload/
 
Abhishek 
0
Riddhi Valecha

Riddhi Valecha

NA 3.1k 186.5k 8y
Hello..
 
Thank you so much ...
I am using FileUpload Control and not textbox. The "runat" attribute is added...
 
Also, Page Name ins @Page Directive and in Code-behind are same.
 
 
My Requirement is -
In the gridview against each row, I have to give a facility to upload multiple files.
0
Manas Mohapatra

Manas Mohapatra

NA 29.3k 3.3m 8y
Issue occurs due to following reason:
 
1. Check your control attributes may be the tag is not properly formatted(
<asp:textbox id="txt" runat="server">

2. In your aspx file,instead of using Codefile use CodeBehind attribute
 
Follow below link that may help you.
 
http://stackoverflow.com/questions/706603/the-name-controlname-does-not-exist-in-the-current-context 
 
http://stackoverflow.com/questions/19027025/name-does-not-exist-in-the-current-context