Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jul 29, 2010 11:35 AM by ironmarot
Jan 14, 2010 02:01 PM|LINK
I want to be able to use the Browse button of the Fileupload control to get a file path, but instead of putting the selected path and filename in the accompanying textbox (as it normally works), I want to add it to a gridview or any other data control.
Basically, I click on the 'Browse' button and search for a file. Once I select the file it will be added to a gridview. So the gridview will display all the files the user has selected.
Any help is appreciated.
VS 2005 2008 asp.net 3.5 html C# c sharp asp.net
Jan 14, 2010 02:54 PM|LINK
Fileupload is a notoriously difficult topic. You could use a flash upload component like SWFUpload. There you can style everything yourself.
You could also hide the upload control and forward to the click on another button to the upload control. But never tried that.
Jan 14, 2010 03:51 PM|LINK
Fileupload is a notoriously difficult topic
rblaettler is spot on with that statement. The fileupload control behaves the way each individual browser type dictates. If you want granular control, go with sblaettler's suggestion and use a third party control.
Jan 14, 2010 05:22 PM|LINK
You can setup a column template for the grid, within this template you can place a fileupload control.
if you want to implement this feature with other controls you have to create a web user control where you can place the controls you need then place this web user control in your aspx page.
Jan 14, 2010 06:31 PM|LINK
just a clue....
onchange="alert('you selected the file: '+ this.value);"/>
file names will be displayed in other control just for display purpose..... when u want to upload actual file, u have to get it from file upload control only.
also, theres no way to hide textbox part of fileupload control. u can just mask it with some other control (like other textbox control with white border and disabled)
hope this helps......
Jan 14, 2010 06:57 PM|LINK
Thanks for the post.
Instead of just uploading each file individually, I wanted to let the user select all the files he needs and then upload them all at the same time. So after choosing all the files they wanted to upload, they'd click 'upload' button and all these files would
upload to the server.
This isn't possible then?
Jan 14, 2010 07:11 PM|LINK
if this is the only requirment, why u want to show file name in grid or some data control..
u can add many uploadfile controls one after other....... user can select file in each control
and when he clicks uploadd button, u can upload file at a time......
also, if u want to upload many files in single button click (single post back), then u must have that many uploadfile controls.
upload file is a control which allows minimum support for tweaking...... and u can not really play around
hope this helps....
Jan 15, 2010 07:08 AM|LINK
As I said, I would use the Flash Upload. With the normal HTML Upload Control you can only upload one file per control.
Check out the demo here:
But keep in mind that flash has it's own issues. Almost all public internet pages that use flash offer an alternative with the normal html control.
Jan 15, 2010 07:28 PM|LINK
Thanks for all the help.
The Flash control was pretty cool, but I then realized it's only cool in IE. It would work in a controlled environment, but that's about it. Many people have documented problems when running it in other browsers. In my case it didn't work in Chrome or firefox.
Basically, I wanted to do something like what ebay has: http://www.silohay.com/ebay.gif
It only has a Browse button, and they upload everything once the user's done. I really don't need the fileupload textbox (I don't really care for the file path), and I don't want to upload each file individually. So the interface is cleaner.
Jan 15, 2010 08:10 PM|LINK
hey..... i created this code..... i hope it helps u...... this is in pure JS and html.....
here goes, complete .aspx page..... u can copy all code and create a new .aspx form and test....
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default3.aspx.vb" Inherits="Default3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title>Test - file upload trick</title>
myOption = document.createElement("Option");
myOption.text = evt;
myOption.value = evt;
<form id="form1" runat="server">
add upto 3 files<br />
<asp:LinkButton ID="q0" runat="server" Text="link1" OnClientClick="return CallUpload();"></asp:LinkButton>
<asp:FileUpload ID="FileUpload2" runat="server" Width="514px"
<asp:FileUpload ID="FileUpload3" runat="server" Width="514px"
<asp:ListBox ID="lstFiles" runat="server" Width="221px"></asp:ListBox>
<asp:Button ID="Upload" runat="server" Text="Button" />
now, in code behind(cs/vb), add following code
Protected Sub Upload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Upload.Click
If Not FileUpload1.PostedFile.FileName = "" Then
FileUpload1.PostedFile.SaveAs("file save path goes here")
If Not FileUpload2.PostedFile.FileName = "" Then
FileUpload2.PostedFile.SaveAs("file save path goes here")
If Not FileUpload3.PostedFile.FileName = "" Then
FileUpload3.PostedFile.SaveAs("file save path goes here")
i hope, this will achive what u looking for.......
give us the feedback...