|
|
|
The user is shown a list of files with checkboxes for the ones they want to download. The user can choose to download 1 to many files. I have it set up to force the prompt to save/download. The program recognizes the files that the user requests, however, the download only works on the first file and doesn't attempt to download any others. i have a download button that call this procedure: |
Click here to copy the following block | Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Response.Write("clicked download... <br>") ' Walk the grid looking for selected rows Dim cb As CheckBox Dim dgi As DataGridItem Dim fn As String
' Walk the grid looking for selected rows For Each dgi In users.Items cb = CType(dgi.Cells(3).FindControl("chkDownload"), CheckBox) If CType(dgi.Cells(3).FindControl("chkDownload"), CheckBox).Checked Then Response.Write("found a checked box") Response.Write(dgi.Cells(1).Text & " is checked <br>") ' Get File Name .. fn = dgi.Cells(1).Text ' ... and download the file. Response.Write("now downloading " & dgi.Cells(1).Text & "... <br>") DownloadFile(fn, True) Else Response.Write(dgi.Cells(1).Text & " is not checked <br>") End If Next End Sub |
When this procedure find a checked box in the datagrid it calls this procedure: |
Click here to copy the following block | Sub DownloadFile(ByVal fname As String, ByVal forceDownload As Boolean) Dim path As IO.path Dim fullpath = Server.MapPath(fname) Dim name = path.GetFileName(fullpath) Dim ext = path.GetExtension(fullpath) Dim type As String = ""
If Not IsDBNull(ext) Then ext = LCase(ext) End If
Select Case ext Case ".htm", ".html" type = "text/HTML" Case ".txt" type = "text/plain" Case ".doc", ".rtf" type = "Application/msword" Case ".csv", ".xls" type = "Application/x-msexcel" Case Else type = "application/octet-stream" End Select
If (forceDownload) Then Response.AppendHeader("content-disposition", _ "attachment; filename=" + name) End If
If type <> "" Then Response.ContentType = type End If
Response.WriteFile (fullpath) Response.End()
End Sub |
Now the procedure called by the button is set to loop, but it doesn't seem to. can anyone help?:confused: |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|