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. Display Image in gridview store in database

Display Image in gridview store in database

Scheduled Pinned Locked Moved ASP.NET
helpcsharpdatabaselinq
9 Posts 4 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.
  • G Offline
    G Offline
    gautamamit8
    wrote on last edited by
    #1

    Hi Coders My Problem is that Image store in database in binary format and I want to display in a gridview but unable 2 do so. If u do this with use of LINQ that is best for me.Anyway u are free to do this with any method. any help would be appreciated Thanks Amit Gautam

    S N C 3 Replies Last reply
    0
    • G gautamamit8

      Hi Coders My Problem is that Image store in database in binary format and I want to display in a gridview but unable 2 do so. If u do this with use of LINQ that is best for me.Anyway u are free to do this with any method. any help would be appreciated Thanks Amit Gautam

      S Offline
      S Offline
      sashidhar
      wrote on last edited by
      #2

      gautamamit8 wrote:

      f u do this with use of LINQ that is best for me.

      Then You have to post in job task..!This forum is for helping to others not to do their work ..! If You are stuck with some where then we can help you..! What You had done until now ..?Where did you stuck..! try this link..! Displaying Image in Gridview from Database[^]

      LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

      G 1 Reply Last reply
      0
      • G gautamamit8

        Hi Coders My Problem is that Image store in database in binary format and I want to display in a gridview but unable 2 do so. If u do this with use of LINQ that is best for me.Anyway u are free to do this with any method. any help would be appreciated Thanks Amit Gautam

        N Offline
        N Offline
        Nishant Singh
        wrote on last edited by
        #3

        Refer this article C# Image to Byte Array and Byte Array to Image Converter Class[^]

        G 1 Reply Last reply
        0
        • S sashidhar

          gautamamit8 wrote:

          f u do this with use of LINQ that is best for me.

          Then You have to post in job task..!This forum is for helping to others not to do their work ..! If You are stuck with some where then we can help you..! What You had done until now ..?Where did you stuck..! try this link..! Displaying Image in Gridview from Database[^]

          LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

          G Offline
          G Offline
          gautamamit8
          wrote on last edited by
          #4

          Till now I store the single image in binary format in database. Even , I can show the image from database single but I dont know how to show them in Grid. The Article Link u given to me is for display image via using path of the Image not in binary format.So that is not helpful and Secondly I'm not here to get complete my work from others I just need a help or a point where i can solve my problem. Thanks for urs kind interest Amit

          S 1 Reply Last reply
          0
          • G gautamamit8

            Till now I store the single image in binary format in database. Even , I can show the image from database single but I dont know how to show them in Grid. The Article Link u given to me is for display image via using path of the Image not in binary format.So that is not helpful and Secondly I'm not here to get complete my work from others I just need a help or a point where i can solve my problem. Thanks for urs kind interest Amit

            S Offline
            S Offline
            sashidhar
            wrote on last edited by
            #5

            Check this..! Its in vb.net You can convert in c#.net http://www.beansoftware.com/asp.net-tutorials/images-database.aspx[^]

            LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

            1 Reply Last reply
            0
            • N Nishant Singh

              Refer this article C# Image to Byte Array and Byte Array to Image Converter Class[^]

              G Offline
              G Offline
              gautamamit8
              wrote on last edited by
              #6

              sorry dear can't work

              N 1 Reply Last reply
              0
              • G gautamamit8

                sorry dear can't work

                N Offline
                N Offline
                Nishant Singh
                wrote on last edited by
                #7

                What is the error that you are getting??

                S 1 Reply Last reply
                0
                • N Nishant Singh

                  What is the error that you are getting??

                  S Offline
                  S Offline
                  sashidhar
                  wrote on last edited by
                  #8

                  He did not get any error because he dont know how to start..!

                  LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

                  1 Reply Last reply
                  0
                  • G gautamamit8

                    Hi Coders My Problem is that Image store in database in binary format and I want to display in a gridview but unable 2 do so. If u do this with use of LINQ that is best for me.Anyway u are free to do this with any method. any help would be appreciated Thanks Amit Gautam

                    C Offline
                    C Offline
                    carlecomm
                    wrote on last edited by
                    #9

                    //upload image public void OnUpload(Object sender, EventArgs e) { int len = Upload.PostedFile.ContentLength; byte[] pic = new byte[len]; Upload.PostedFile.InputStream.Read (pic, 0, len); SqlConnection connection = new SqlConnection (@"server=INDIA INDIA;database=iSense;uid=sa;pwd=india"); try { connection.Open (); SqlCommand cmd = new SqlCommand ("insert into Image " + "(Picture, Comment) values (@pic, @text)", connection); cmd.Parameters.Add ("@pic", pic); cmd.Parameters.Add ("@text", Comment.Text); cmd.ExecuteNonQuery (); } finally { connection.Close (); } } //load image private void Page_Load(object sender, System.EventArgs e) { MemoryStream stream = new MemoryStream (); SqlConnection connection = new SqlConnection (@"server=INDIA INDIA;database=iSense;uid=sa;pwd=india"); try { connection.Open (); SqlCommand command = new SqlCommand ("select Picture from Image where id"], connection); byte[] image = (byte[]) command.ExecuteScalar (); stream.Write (image, 0, image.Length); Bitmap bitmap = new Bitmap (stream); Response.ContentType = "image/gif"; bitmap.Save (Response.OutputStream, ImageFormat.Gif); } catch { string strblandImagePath = Server.MapPath(""); strblandImagePath += "NoImg.gif"; FileStream FileBlandImagestream = File.OpenRead(strblandImagePath); Bitmap bitImage = new Bitmap(FileBlandImagestream); Response.ContentType = "image/gif"; bitImage.Save(Response.OutputStream, ImageFormat.Gif); } finally { connection.Close (); stream.Close (); } }

                    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