Asp.net 如何从根目录中的文件夹在网格中显示上载的图像文件?
我用来将数据保存在文件夹中的Aspx.vb代码Asp.net 如何从根目录中的文件夹在网格中显示上载的图像文件?,asp.net,vb.net,Asp.net,Vb.net,我用来将数据保存在文件夹中的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 >
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
上传后,我想在网格中的浏览按钮后面显示上传的每个图像您需要在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>
@RameshRajendran?!那你为什么在这里评论?因此,这不是一个分享你“观点”(更不用说基于仇恨的观点)的论坛。例如,如果我同意我的观点,我会说仇恨是无知的同义词;而且VB.NET和C#基本相同;事实上,纯.NET语言是VB(微软的语言),C#是一种最新的语言,其唯一目的是补偿非理性的仇恨并将开发者带到.NET:)@son,请进一步解释你想做什么。。您说要上载“该”图像,但我在代码中看到,您正在接受多个文件。@AndréFigueiredo:我想在网格中的相应上载行显示每个图像