I am having Gridivew with fileupload which has Add more rows operation. When i Click on Add more rows the fileupload control loses the file. I need to save all the added rows on a single submit button which should save all the files on a folder. Kindly help me.
Thanks in advance
You cannot persist the input type="file"
state after an HTTPPost. ( In ASP.NET jargon this will translate as cannot persist asp:FileUpload
s value after PostBack ).
Its designed that way to address security issues. There are so many examples of the same question answered here at StackOverflow ( search it ). There is a Session
hack that provides a workaround but its for single file. Link here: https://stackoverflow.com/a/18656681/17447
Theoretically you could still do it using a Dictionary<int, FileUpload>
. The first parameter will the GridViewRow.RowIndex
and the second parameter would be the asp:FileUpload
control on that row. You can start by adding all rows at the first PostBack to a session and then updating it when file.HasFile and so. But IMHO, don't do that because
So these are the things you can do,
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.