从SQL Server在gridview中上载图像 [英] Upload image in gridview from sql server

查看:87
本文介绍了从SQL Server在gridview中上载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友...我创建了一个Web应用程序,以从gridview的数据库中检索图像.完成数据库上传,图像已存储在应用程序目录中. (图像).wen在aspx页面中涉及gridview,我无法显示图像.会是什么问题..

我的aspx文件..

Hi friend... I have created a web application to retrieve images from database in gridview. Uploading database is done and the images are getting stored in the application directory. (Images).. Wen it comes to gridview inside aspx page i am not able to show the images. What will be the problem..

My aspx file..

<asp:TemplateField HeaderText ="Image">
<itemtemplate>
    <asp:Image ID="imgimage" ImageUrl ='<%#Bind("Art_Image", "../Images/{0}") %>' runat="server"/>
</itemtemplate>
<edititemtemplate>
    <asp:FileUpload ID="filupload1" runat="server" />
</edititemtemplate>
<footertemplate>
    <asp:FileUpload ID="filupload1" runat="server" />
</footertemplate>


我的编码文件是....


and my coding file is....

If fileupload1.HasFile Then
           Try

               If ((fileupload1.PostedFile.ContentType = "image/jpeg") Or
                   (fileupload1.PostedFile.ContentType = "image/png") Or
                   (fileupload1.PostedFile.ContentType = "image/gif") Or
                   (fileupload1.PostedFile.ContentType = "image/swf")) Then

                   If fileupload1.PostedFile.ContentLength < 1024000 Then


                       filename = Path.GetFileName(fileupload1.PostedFile.FileName).ToLower
                       fileupload1.PostedFile.SaveAs(Server.MapPath("../Images/") & filename)

                       sqlimage = Server.MapPath("../Images/") & filename


                       lblerror.Text = "Fileuploaded"
                   Else
                       lblerror.Text = "File not uploaded"
                   End If

推荐答案

使用
<asp:ImageField DataImageUrlField="Art_Image" DataImageUrlFormatString="~/pics/{0}.jpg"></asp:ImageField>


这篇关于从SQL Server在gridview中上载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆