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. ImageButton in a GridView

ImageButton in a GridView

Scheduled Pinned Locked Moved ASP.NET
help
3 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.
  • C Offline
    C Offline
    Cyberpulse
    wrote on last edited by
    #1

    I have an ImageButton in the Item Template of the fourth column of a gridview. I am trying to access it in the *.aspx.cs file but am unable to do so. I need this button to pass it as a parameter to a method and have tried multiple routes including this one which seemed like something that should have worked:- (ImageButton)Gridview.FindControl("EditButton"); "EditButton" is the name of the ImageButton Could anyone help me out. Thanks, Sudeep

    B 1 Reply Last reply
    0
    • C Cyberpulse

      I have an ImageButton in the Item Template of the fourth column of a gridview. I am trying to access it in the *.aspx.cs file but am unable to do so. I need this button to pass it as a parameter to a method and have tried multiple routes including this one which seemed like something that should have worked:- (ImageButton)Gridview.FindControl("EditButton"); "EditButton" is the name of the ImageButton Could anyone help me out. Thanks, Sudeep

      B Offline
      B Offline
      boy pockets
      wrote on last edited by
      #2

      When calling a method such as this: (ImageButton)Gridview.FindControl("EditButton"); you need to tell it which row to get the control from. So it should look like this: (ImageButton)Gridview.Rows[0].FindControl("EditButton"); The number (0) is the index of the row. Alternatively you can get it in the ImageButtons onClick method. In this case, the sender parameter (comes in as an object) is the ImageButton.

      C 1 Reply Last reply
      0
      • B boy pockets

        When calling a method such as this: (ImageButton)Gridview.FindControl("EditButton"); you need to tell it which row to get the control from. So it should look like this: (ImageButton)Gridview.Rows[0].FindControl("EditButton"); The number (0) is the index of the row. Alternatively you can get it in the ImageButtons onClick method. In this case, the sender parameter (comes in as an object) is the ImageButton.

        C Offline
        C Offline
        Cyberpulse
        wrote on last edited by
        #3

        Thanks a ton.

        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