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. C# Gridview and image field

C# Gridview and image field

Scheduled Pinned Locked Moved ASP.NET
csharpdatabasewpfwcfhelp
8 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.
  • I Offline
    I Offline
    InvalidTypecast
    wrote on last edited by
    #1

    If I have an image field in my gridview is there a way to tie it to a link so that it is clickable? I know there is the imagebutton column, but I don't see a way of populating the image from the database like I am doing with the image column. For example, I have a database with a column called "image" which has the relative path on my webserver to the image. Right now I am just binding the image column to the path for its imageurl field and I get the correct image to show. The problem is that I see no way of making it a link so that people can click on it. Alternately, I see no way of binding the imagebutton field to the database "image" column. Maybe I am just overlooking it?

    N J 2 Replies Last reply
    0
    • I InvalidTypecast

      If I have an image field in my gridview is there a way to tie it to a link so that it is clickable? I know there is the imagebutton column, but I don't see a way of populating the image from the database like I am doing with the image column. For example, I have a database with a column called "image" which has the relative path on my webserver to the image. Right now I am just binding the image column to the path for its imageurl field and I get the correct image to show. The problem is that I see no way of making it a link so that people can click on it. Alternately, I see no way of binding the imagebutton field to the database "image" column. Maybe I am just overlooking it?

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Use a template column and wrap the image in a hyperlink control.


      only two letters away from being an asset

      I 1 Reply Last reply
      0
      • N Not Active

        Use a template column and wrap the image in a hyperlink control.


        only two letters away from being an asset

        I Offline
        I Offline
        InvalidTypecast
        wrote on last edited by
        #3

        I see the option to add a TemplateField, but I am not sure how to do the wrapping.

        S 1 Reply Last reply
        0
        • I InvalidTypecast

          I see the option to add a TemplateField, but I am not sure how to do the wrapping.

          S Offline
          S Offline
          Sathesh Sakthivel
          wrote on last edited by
          #4

          this[^]will help you in Wrapping in the template field.

          Regards, Satips.:rose:

          N 1 Reply Last reply
          0
          • I InvalidTypecast

            If I have an image field in my gridview is there a way to tie it to a link so that it is clickable? I know there is the imagebutton column, but I don't see a way of populating the image from the database like I am doing with the image column. For example, I have a database with a column called "image" which has the relative path on my webserver to the image. Right now I am just binding the image column to the path for its imageurl field and I get the correct image to show. The problem is that I see no way of making it a link so that people can click on it. Alternately, I see no way of binding the imagebutton field to the database "image" column. Maybe I am just overlooking it?

            J Offline
            J Offline
            Jay_se
            wrote on last edited by
            #5

            It means, <a><img></img></a> I have mentioned the concept only. Use this format in your TemplateColumn

            Regards, Jay :)

            I 1 Reply Last reply
            0
            • S Sathesh Sakthivel

              this[^]will help you in Wrapping in the template field.

              Regards, Satips.:rose:

              N Offline
              N Offline
              Not Active
              wrote on last edited by
              #6

              The article you reference is completely off the topic and is no help at all in the problem at hand.


              only two letters away from being an asset

              1 Reply Last reply
              0
              • J Jay_se

                It means, <a><img></img></a> I have mentioned the concept only. Use this format in your TemplateColumn

                Regards, Jay :)

                I Offline
                I Offline
                InvalidTypecast
                wrote on last edited by
                #7

                That doesn't seem to work because it adds the formatting inside the tag. So if I used your example it would do ![](<a><img>images/imageName.jpg</img></a>/>)

                I 1 Reply Last reply
                0
                • I InvalidTypecast

                  That doesn't seem to work because it adds the formatting inside the tag. So if I used your example it would do ![](<a><img>images/imageName.jpg</img></a>/>)

                  I Offline
                  I Offline
                  InvalidTypecast
                  wrote on last edited by
                  #8

                  Ok I figured it out. Thanks for getting me thinking straight. I had to do it from a hyperlink field I changed the DataTextField to my image column in the database and then I used the DataTextFormatString

                  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