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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Image in GridView becomes "System.Byte[]"

Image in GridView becomes "System.Byte[]"

Scheduled Pinned Locked Moved ASP.NET
databasehelptutorialquestion
2 Posts 2 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.
  • Q Offline
    Q Offline
    Q_Quek
    wrote on last edited by
    #1

    Hi, I try to use gridview with objectdatasource to obtain the images from the sql database. Within the database, a datafield is declare as "image" datatype. Now in my gridview, it doesn't show me the image instead of showing me a text "System.Byte[]" May I know how to solve it. What column I should use for the image? ImageField, TemplateField, Bound Field? Please help me!!! Calvin ****

    N 1 Reply Last reply
    0
    • Q Q_Quek

      Hi, I try to use gridview with objectdatasource to obtain the images from the sql database. Within the database, a datafield is declare as "image" datatype. Now in my gridview, it doesn't show me the image instead of showing me a text "System.Byte[]" May I know how to solve it. What column I should use for the image? ImageField, TemplateField, Bound Field? Please help me!!! Calvin ****

      N Offline
      N Offline
      nnnsreenu
      wrote on last edited by
      #2

      This problem is converting Image to string, I will send example verify that, Byte[] blob = null; blob = new Byte[(dr.GetBytes(0, 0, null, 0, int.MaxValue))]; dr.GetBytes(0, 0, blob, 0, blob.Length); OR.......... SqlCommand cmd = new SqlCommand("select Doc,DocTitle,DocType from tblResumeUpload where Docid=" + queryRequest, Conn); Conn.Open(); Byte[] blob = null; //blob = new Byte[1024]; // Execute the SQL statement SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); //Byte[] blob = (byte[])dr["doc"]; //blob = Convert.ToString (dr[0]); // Get the file size and file data from the retrieved record blob = new Byte[(dr.GetBytes(0, 0, null, 0, int.MaxValue))]; dr.GetBytes(0, 0, blob, 0, blob.Length); ok bye sreenu

      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