Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How to use asp:ImageField in a GridView

How to use asp:ImageField in a GridView

Scheduled Pinned Locked Moved ASP.NET
htmldatabasesysadminhelptutorial
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RoyRose78
    wrote on last edited by
    #1

    Hi all, I'm using GridView with an ImageField column and somehow it doesn't display the pictures in my db. This is the code for adding new picture to the db (which I took from codeproject site) if (!Page.IsValid) return; if (!FileUpload1.HasFile) return; try { int len = FileUpload1.PostedFile.ContentLength; byte[] pic = new byte[len]; FileUpload1.PostedFile.InputStream.Read(pic, 0, len); int glrId = int.Parse(_GallaryDropDownList.SelectedValue); _engine.AddPicture(gallrId, pic, _DescTextBox.Text); } catch {... } The GridView markup is the following: <asp:GridView ID="GridView1" runat="server" ForeColor="Navy" Width="100%" AutoGenerateColumns="False" DataKeyNames="picID" DataSourceID="_PicturesSqlDataSource" Font-Names="Arial" Font-Size="11pt"> <Columns> <asp:BoundField DataField="picID" HeaderText="picID" InsertVisible="False" ReadOnly="True" SortExpression="picID" Visible="False" /> <asp:BoundField DataField="picGlrID" HeaderText="picGlrID" SortExpression="picGlrID" Visible="False" /> <asp:ImageField DataAlternateTextField="picDEscription" DataImageUrlField="picData" HeaderText="picture"> </asp:ImageField> <asp:BoundField DataField="picDEscription" HeaderText="description" SortExpression="picDEscription" /> <asp:TemplateField> <ItemTemplate> <asp:CheckBox ID="_SelForDelCheckBox" runat="server" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> When I go to that page, I can see the rows but I cannot see the images, I can see the alt text instead.. Can you help me with that? What am I doing wrong? Thank you, Roy.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups