|
First you need to place a gridview. Add a template column. In ItemTemplate add
<input type="file" id="MyFileUpload" runat="server">
Assume you need to upload 5 file. So you need 5 rows in grid view. For that create a dummy datatable with 5 records and bind to gridview. Now you will see gridview binding with 5 records and in each row you will get each file upload control.
Down to gridview place a button. Inside button click write
for ( int i=0;i<GridviewRows;i++)
{
HtmlInputFile fileUpload = (HtmlInputFile)GridView.Rows[i].Cells[FileUploadCell].
FindControl("MyFileUpload");
fileUpload.PostedFile.SaveAs("YourServerLocation");
}
FindControl method will find the control from gridview and give you the object. Using that object you can do upload. You need to handle exception efficiently. This will raise NullReferenceException if FindControl() is not getting the object. So make sure that you will specify the cell where FileUploadControl resides.
|
|
|
|
|
Hi Navaneeth,
Thanks for your code. But my problem is, my client dont want that much file upload control to be seen in the UI. The requirement of my client is, he needs only one file upload control and in one click he wants to select more than one file at time.
Can we create any web user control. Do you have any suggestion for that.
Thanks and Regards,
Hariharan C.
|
|
|
|
|
Hari_1010 wrote: my client dont want that much file upload control to be seen in the UI. The requirement of my client is, he needs only one file upload control and in one click he wants to select more than one file at time.
Why don't you tell this first. So whatever code I written for you in previous posts became unusable . No issues, let's start again from the scratch.
Now for this requirement we can follow the method what that article say's. But you can't reuse the article code since it won't work perfectly. You need to do some small changes in his code. You can try with this
1. Put one file upload control.( As your client said )
2. Put list box just to show the files selected. No much role in this movie
3. Place two buttons with "Add to List", and "Upload" texts.
4. OnClick of "Add to List" button, get the postedfile object and store that in one arraylist.
5. Now move arraylist to one session. ( Used to get the value across page postbaccks )
6. On Upload button click cast session to arraylist. Then cast array list object to HttpPostedFile object. Now use SaveAs() method in that object
In that article author is not using sessions. Your Upload button code would be
ArrayList ObjArr = (ArrayList)Session["files"];
HttpPostedFile postFile = (HttpPostedFile)ObjArr[0];
Response.Write(postFile.FileName);
Response.Write(postFile.ContentLength.ToString());
postFile.SaveAs(Server.MapPath("/filename.zip"));
|
|
|
|
|
Hi Navaneeth,
My problem is I want to select more than one file at one click. For example, take winamp or windows media player. If we want to play songs from a movie, what we will do is browse and select all songs.
Like that I want to work in ASP.Net 2.0. By clicking the Upload file control, I want to select more than one file at a time and I want to upload it into my database.
So could you please help me out to solve this problem. Please...its very essential for my project.
Thanks and Regards,
Hariharan C
|
|
|
|
|
Hari_1010 wrote: Like that I want to work in ASP.Net 2.0. By clicking the Upload file control, I want to select more than one file at a time and I want to upload it into my database.
Same method what I suggested will do this
|
|
|
|
|
hi friend good morning
i am using ajax panel where i have a text box.when i input like this:- <asdf
then http="" error="" 500="" occurred....error:-
"sys.webfrom.pagereqestmanagerserver="" error:an="" unknown="" occurred="" while="" processing="" the="" request="" on="" server,the="" status="" code="" returned="" from="" server="" was:500"
help="" me
=""
<div="" class="ForumSig">Piyush Vardhan Singh
Programmer
TAS NewDelhi
India
9313077379
|
|
|
|
|
input like greater then in html and abcd
Piyush Vardhan Singh
Programmer
TAS NewDelhi
India
9313077379
|
|
|
|
|
i would like to know how to create an application were the image will change color based on the database value(example '1'=red '0'=green)
And also a code to insert table in the webform based on the input of columns and rows from a textbox
Row: 3
column: 2
next a table with 3 rows and 2 columns are created
|
|
|
|
|
Add these three controls to xml page.
<asp:textbox id="txtColumns" runat="server">
<asp:button id="btnGenerate" runat="server" onclick="btnGenerate_Click" text="Generate">
<asp:gridview id="mainDataGrid" runat="server">
then add this code behid the button on click event
DataTable dt = new DataTable();
if (txtColumns.Text.Length > 0)
{
string[] str = txtColumns.Text.Split(',');
foreach (String st in str)
{
dt.Columns.Add(st);
}
DataRow dr = dt.NewRow();
dt.Rows.Add(dr);
mainDataGrid.DataSource = dt;
mainDataGrid.DataBind();
}
You can also use switch statement for decision making in selecting color.
God Bless you.
Always do good to others
|
|
|
|
|
i'm appricate your promptnes in sending me a reply thank you
I prefer using visual basic to c# and converted your code to visual basic from www.codechanger.com
does it use 2 textboxes and 1 button
does it accept the inputs from the rows and columns
|
|
|
|
|
hi there
i would like to know wht the DataTable and DataRow is for
|
|
|
|
|
datatable is a logical table in the memory and datarow is logical row in the memory.
God Bless you.
Always do good to others
|
|
|
|
|
wht controls are added to the xml page???
|
|
|
|
|
These are controls for adding.
asp:TextBox
asp:Button
asp:GridView
God Bless you.
Always do good to others
|
|
|
|
|
duo!@# wrote: i would like to know how to create an application were the image will change color based on the database value(example '1'=red '0'=green)
You can take two image and select the image to the control based on the database criterion.
duo!@# wrote: And also a code to insert table in the webform based on the input of columns and rows from a textbox
Row: 3
column: 2
next a table with 3 rows and 2 columns are created
What you need to do is to create the html table and rows is c# and add it to another parent control like panel.
Apurva Kaushal
|
|
|
|
|
Hi all
The code segment below creates a table with some images. The images will be displayed in a triangular shape. ie. 1 image in a row, 2 in the next like...
<html>
<head>
<title>
welcome to ImageList
</title>
</head>
<Body>
<table width=600>
<% for X = 0 to 4 %>
<tr>
<% if x=0 then %>
<td colspan=7 align="center"><img src="images/11.bmp"><% response.write("cell "&y)%>.</td>
<% end if %>
<% if x=1 then %>
<% for y = 0 to 1 %>
<td colspan=4 align="center"><img src="images/11.bmp"><% response.write("cell "&y)%>.</td>
<% next %>
<% end if %>
<% if x=2 then %>
<% for y = 0 to 3 %>
<td colspan=2 align="center"><img src="images/11.bmp"><% response.write("cell "&y)%>.</td>
<% next %>
<% end if %>
<% if x=3 then %>
<% for y = 0 to 7 %>
<td align="center"><img src="images/11.bmp"><% response.write("cell "&y)%>.</td>
<% next %>
<% end if %>
</tr>
<% next %>
</table>
</Body>
</html>
My problem in that, i would like to insert some spaces in between rows..
how i can achieve this........?
waiting for you valuable suggestions.....
Thanks in adavance
Sebastian
|
|
|
|
|
How about creating a spacer image ?
|
|
|
|
|
Hi,
Thats really a nice idea.........
Thanks a lot.........
Sebastian
|
|
|
|
|
I am getting subject error while using a dataset to populate ReportDocument object.(.Net 2005)
Any idea please....
The great pleasure in life is doing what people say you cannot do.
|
|
|
|
|
Hi All
I have ASP File on which there is a Button which Calls the function from Vbs File , the function in turn set the filesystemobject
dim objfso
set objFSO = CreateObject("scripting.Filesystemobject")
But when function is called form ASP file it gives error
ActiveX component can't be created .
Thanks & Wishes
Navneet Hegde
Develop2Program & Program2Develop
|
|
|
|
|
Hello friends,
I am very new to asp.net .I done a project in asp.net with C# .(.Net version 1.1)After uploading the project in server, some of my Button events,linkButton events,and image Button are not working or not activated.same page is refreshing....This problem only in internet explorer .But it is working fine in local(same IE).This is working fine in Mozilla browser........I didnt get a solution .....please help me to find out this problem.....
|
|
|
|
|
Hi all,
I want to upload multiple files in ASP.Net 2.0 with the file upload control. So I have download the source code "Upload multiple files Hotmail style -
Kwame Hubbard" from the following site.
http://www.codeproject.com/aspnet/multiuploads.asp
But now I am getting an error "Could not load type 'webchange.attachme'". So could you please help me out to solve this problem.
Thanks and Regards,
Hariharan C
|
|
|
|
|
Get it[^]
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|
|
Hi Satips,
That error is solved. Now I am able to run that applicaion. Great thanks for your help. But now I am getting an error "Error - a file name must be specified." Could you please help me to solve this problem.
Thanks and Regards,
Hariharan C
|
|
|
|
|
Hari_1010 wrote: "Error - a file name must be specified."
I don't know why you got this error.
Better ask it in the Kwame Hubbard in his article itself. Because you have followed his Code.
You will get a reply from him.
Regards,
Satips.
Don't walk in front of me, I may not follow;
Don't walk behind me, I may not lead;
Walk beside me, and just be my friend. - Albert Camus
|
|
|
|