Dear all,
 
I need to upload multiple files in the gridview, but I am not able to upload all the selected files on particular folder.
 
I am sharing my code and design.
 
Please guide - where am I going wrong now.
 

ASPX Page Design –

<title></p> <p><link href=”App_Themes/Scripts/uploadify.css” rel=”stylesheet”/></p> <p> </head></p> <p><body></p> <p><script type=”text/javascript” src=” App_Themes/Scripts/jquery-.3.2.js”></script></p> <p><script type=”text/javascript” src=” App_Themes/Scripts/jquery.Multifile.js”></script></p> <p><form id=”form1” runat=”server”></p> <p><table></p> <p><tr></p> <p><td></p> <p><asp:radiobuttonlist id=”radiobtnlistSerialNumber” runat=”server”></asp:radiobuttonlist></p> <p></td></p> <p><td></p> <p><asp:Fileupload id=”multiplefileupload” runat=”server” class=”multi”/></p> <p></td></p> <p></tr></p> <p><tr></p> <p><td></p> <p><asp:radiobuttonlist id=”radiobtnlistSerialNumber” runat=”server”></asp:radiobuttonlist></p> <p></td></p> <p><tr></p> <p><td colspan=”2”></p> <p><asp:GridView id=”grdData” runat=”server” AutogenerateColumns=”true”></p> <p></asp:GridView></p> <p></td></p> <p></tr></p> <p><tr></p> <p><td></p> <p><asp:button id=”UploadFilesBtn” runat=”server” Text=”Upload Multiple Files” onClick=” UploadFilesBtn _Click”/></p> <p></td></p> <p></tr></p> <p></table></p> <p></form></p> <p></body></p> <p>ASPX.cs file –</p> <p>Protected void UploadFilesBtn _Click(object sender, EventArgs, e)</p> <p>{</p> <p>Try</p> <p>{</p> <p>HttpFileCollection hfc = Request.Files;</p> <p>If(radiobtnlistSerialNumber.SelectedIndex >= 0)</p> <p>{</p> <p>If(multiplefileupload.HasFile == true)</p> <p>{</p> <p>Foreach(Gridviewrow row in grdData.Rows)</p> <p>{</p> <p>If(row.cells[2].text == radiobtnlistSerialNumber.Selectedvalue.tostring())</p> <p>{</p> <p>HttpFileCollection hcoll = Request.Files;</p> <p>Int32 totalcount = hcoll.Count;</p> <p>For(int i=0; I < totalcount-1; i++)</p> <p>{</p> <p> HttpPostedFile hpf =hcoll[i];</p> <p>String s = ConfigurationManager.AppSettings[“UploadFolderPath”].ToString();</p> <p>Multiplefileupload.PostedFile.SaveAs(s +”\\”+System.DateTime.Now.Tostring(“ddMMMyyyyhhmmss”) + multiplefileupload.FileName);</p> <p>//Insert into table – values (radiobtnlistSerialNumber.Selectedvalue.tostring(), </p> <p>//System.DateTime.Now.Tostring(“ddMMMyyyyhhmmss”) + multiplefileupload.FileName, </p> <p>//Row.Cells[4].text.tostring());</p> <p>}</p> <p>}</p> <p>}</p> <p>}</p> <p>}</p> <p>}</p> <p>}</p> Please guide - This is a bit urgent and important...</div></div></article><template id="P:4"></template><section class="comments" id="replies"><header class="comments-head"><span class="comments-badge" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" width="19" height="19" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M3 3h10a2 2 0 0 1 2 2v4.5a2 2 0 0 1-2 2H7.5L4 14.5V11.5H3a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"></path></svg></span><div><h2 class="comments-title">1 Reply</h2><p class="comments-sub">Know the answer? Post it — somebody with the same question will find it here.</p></div></header><div class="comment-signin"><span class="comment-signin-badge" aria-hidden="true"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.6"><path d="M11.5 3.5h3.2a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1h-3.2" stroke-linecap="round"></path><path d="M4.5 10h7" stroke-linecap="round"></path><path d="M8.8 7.2 11.6 10l-2.8 2.8" stroke-linecap="round" stroke-linejoin="round"></path></svg></span><div class="comment-signin-body"><p class="comment-signin-title">Sign in to <!-- -->answer this question</p><p class="comment-signin-text">It is the same account you read, post and publish with — and you will come straight back to this page.</p></div><div class="comment-signin-actions"><a class="btn primary-btn comment-signin-btn" href="/login?returnurl=%2Fforums%2Fmultiple-file-upload-all-files-are-not-getting-uploaded">Sign in</a><a class="comment-signin-alt" href="/register?returnurl=%2Fforums%2Fmultiple-file-upload-all-files-are-not-getting-uploaded">Create an account</a></div></div><ul class="comment-list"><li class="comment-thread"><article class="comment"><a class="comment-photo-link" href="/members/khaja-moiz" title="Khaja Moizuddin"><img class="comment-photo" src="https://cdn.c-sharpcorner.com/uploadfile/authorimage/e3224a20250623063451.webp" alt="Khaja Moizuddin" title="Khaja Moizuddin" loading="lazy" data-avatar-name="Khaja Moizuddin" referrerPolicy="no-referrer"/></a><div class="comment-main"><div class="comment-head"><p class="comment-byline"><a href="/members/khaja-moiz" class="comment-author">Khaja Moizuddin</a><span class="posted-when" tabindex="0"><time class="posted-when-value comment-time" dateTime="2016-12-04T00:00:04.430Z">10y<!-- --> ago</time><span class="posted-when-pop" role="tooltip"><span>Posted<!-- --> <!-- -->Dec 4, 2016, 12:00 AM</span></span></span></p></div><div class="article-body"><div>https://www.codeproject.com/questions/888652/how-to-upload-multiple-images-to-gridview</div><div> http://www.aspsnippets.com/Articles/Upload-images-to-folder-and-display-uploaded-images-in-ASPNet-GridView-using-C-and-VBNet.aspx</div><div>http://stackoverflow.com/questions/27780090/display-images-in-gridview-multiple-images</div><div>http://www.webcodeexpert.com/2013/08/how-to-binduploaddownloaddelete-image.html</div><div>http://www.aspdotnet-suresh.com/2011/03/how-to-save-images-into-folder-and.html</div><div>https://dotnetdrizzles.blogspot.in/2015/01/multiple-image-upload-in-single-button.html</div><div>http://ajaxuploader.com/image-upload.htm</div><div>http://www.dotnetfox.com/articles/store-images-to-database-and-bind-to-gridview-in-Asp-Net-1114.aspx</div><div>  </div><div> </div><div>Refer these blogs for your requirement.</div><div>Hope this helps you. </div></div><div class="comment-foot"><span class="reply-vote"><a href="/login?returnurl=%2Fforums%2Fmultiple-file-upload-all-files-are-not-getting-uploaded" class="reply-vote-btn reply-vote-up" title="Sign in to vote up" aria-label="Vote up"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 2.5 14.5 12h-13z"></path></svg></a><span class="reply-vote-score" title="0 up, 0 down">0</span><a href="/login?returnurl=%2Fforums%2Fmultiple-file-upload-all-files-are-not-getting-uploaded" class="reply-vote-btn reply-vote-down" title="Sign in to vote down" aria-label="Vote down"><svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><path d="M8 13.5 1.5 4h13z"></path></svg></a></span></div></div></article></li></ul></section></div></div><script>$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};$RS("S:2","P:2")</script><script>self.__next_f.push([1,"54:[\"$\",\"$L4f\",null,{\"markup\":\"\u003cdiv id=\\\"ezoic-pub-ad-placeholder-144\\\"\u003e\u003c/div\u003e\",\"scripts\":[{\"attrs\":{},\"text\":\"\\n ezstandalone.cmd.push(function () {\\n ezstandalone.showAds(144);\\n });\\n\"}],\"ezoicPlaceholder\":144,\"className\":\"discussion-ad\"}]\n"])</script><div hidden id="S:4"><div class="discussion-ad ad-unfilled"><div id="ezoic-pub-ad-placeholder-144"></div></div></div><script>$RS("S:4","P:4")</script><script>$RC("B:1","S:1")</script></body></html>