javascript - 下载在网格视图中检查的文件的更好方法
问题描述
我有一个网格视图,其中有一列复选框,然后是几列数据。选择一行时,将显示其对应的图像。任何行都可以在不被选中的情况下进行检查,当单击下载按钮时,应下载所有检查了相应行的图像。现在我有一个 for 循环遍历每一行并找到复选框并查看它是否被选中,这需要太长时间。选中复选框时,有没有办法访问相应行的数据?
For Each row As GridViewRow In gv1.Rows
Dim chkBox As CheckBox = TryCast(row.FindControl("cBox"), CheckBox)
If chkBox.Checked Then
Dim full = row.Cells(1).Text & "B" & row.Cells(3).Text
IO.File.Copy(serv & full & ".TIF", Path.Combine(temp, full & ".TIF"), True)
End If
Next
解决方案
这对我来说非常有效,非常有效。是 IO 副本花费了太长时间。
Using zip As New ZipFile()
zip.AlternateEncodingUsage = ZipOption.AsNecessary
zip.AddDirectoryByName("Drawings")
For Each row As GridViewRow In gv1.Rows
If TryCast(row.FindControl("cBox"), CheckBox).Checked Then
found = True
Dim filepath = serv & row.Cells(1).Text & "B" & row.Cells(3).Text & ".TIF"
zip.AddFile(filepath, "Drawings")
End If
Next
If found Then
Response.Clear()
Response.BufferOutput = False
Dim zipname As String = [String].Format("Drawings_{0}.zip", DateTime.Now.ToString("yyyy-MM-dd-HH:mm:ss"))
Response.ContentType = "application/zip"
Response.AddHeader("content-disposition", "attachment; filename=" + zipname)
zip.Save(Response.OutputStream)
Response.End()
Else
reSetup()
End If
End Using
推荐阅读
- amazon-web-services - 如何在一个 terraform 文件中创建 2 个 ASG,并附加一个 ELB?
- java - 如果 Spring 可以成功拦截 @Configuration 类中的类内函数调用,为什么它在常规 bean 中不支持呢?
- javascript - 使用 jquery.timeline.min.js 未显示事件
- google-sheets - 将公式转换为 ArrayFormula
- ssis - 将 csv 文件写入 Azure Blob 存储时,是否可以将 SSIS 配置为将 NULL 表示为 BLANK 而不是 \N?
- angular - 如何在 OnInit 之后更新视图上的属性绑定?(角度)
- oracle - 删除并重新创建表上具有列表分区的全局索引
- python-3.x - 将numpy数组的每个2字符字符串元素拆分为1字符字符串元素的最快方法?
- angular - 代码推送发布良好,但未到达应用程序
- excel - 将 VLOOKUP 用于十进制数时 Excel 中的 N/A 问题