用于将数据保存在文件夹中的Aspx.vb代码。
Try
Dim j As Integer = 0
Dim hfc As HttpFileCollection = Request.Files
Dim PathName As String
For i As Integer = 0 To hfc.Count - 1
Dim hpf As HttpPostedFile = hfc(i)
If hpf.ContentLength > 0 Then
PathName = System.IO.Path.GetFileName(hpf.FileName)
Dim BookingNumber As String = objWHParent.WHImageTabList.ToList().Item(i).BookingNumber
Dim FileName As String = BookingNumber + "_WRH_" + (i.ToString()) + PathName
hpf.SaveAs(Server.MapPath("~/UploadedImages\") & FileName)
objWHParent.WHImageTabList.ToList().Item(i).FilePath = FileName
objWHParent.WHImageTabList.ToList().Item(i).Flag = "Warehouse"
End If
Next
Catch generatedExceptionName As Exception
Throw
End Try
上传后我想显示网格中浏览按钮后面上传的每张图片
答案 0 :(得分:1)
您需要在gridview上添加图像控件,并从您的数据源中提供URL。请参阅以下代码以供参考:
<asp:GridView ID="gvFolder" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundField HeaderText = "Image Name" DataField="ImageName" />
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("ImageURL") %>'Height="150px" Width="150px"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>