c# asp.net displaying image in gridview

后端 未结 3 1934
悲哀的现实
悲哀的现实 2021-01-27 15:33

I wish to display an image in a gridview.

I have a database with 4 columns - id, author, comment, filename (which holds the img path)

http://postimg.org/image/4l

相关标签:
3条回答
  • 2021-01-27 15:50
    ImageUrl ='<%# "Images\\"+Eval("FileName") %>'
    

    try this way...

    0 讨论(0)
  • 2021-01-27 15:59

    in your design view click on smart tag of your gridview and select 'Edit Columns...' then in the opened window create an ImageField and in it's properties on right side of window, under 'Data' pane set the property 'DataImageUrlField' to the field that contains your urls that in this case is 'FileName'. it should works.

    0 讨论(0)
  • 2021-01-27 16:07

    Dont set full path ,

     string savepath = "~/Images/" + Filename;
    cmd.Parameters.AddWithValue("@filename", savepath));
    

    just change this line it will work

    and even change

     fileupload.SaveAs(Server.MapPath("~/Images/" + FileName));
    
    0 讨论(0)
提交回复
热议问题