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. Image button in Gridview

Image button in Gridview

Scheduled Pinned Locked Moved ASP.NET
question
5 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.
  • D Offline
    D Offline
    danasegaranea
    wrote on last edited by
    #1

    Hi All, I am adding one imagebutton in gridview using the "RowDataBound" method. But I could not able to found the onclick/runtat event.. How can i add this one ? ImageButton imgSortAssendingbyId = new ImageButton(); Thanks in Advance Dana

    S G 2 Replies Last reply
    0
    • D danasegaranea

      Hi All, I am adding one imagebutton in gridview using the "RowDataBound" method. But I could not able to found the onclick/runtat event.. How can i add this one ? ImageButton imgSortAssendingbyId = new ImageButton(); Thanks in Advance Dana

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

      hi.. use this code in GVList_RowDataBound(...) Dim btnDel As ImageButton, btnUpd As ImageButton, lbexp As Label If e.Row.RowType = DataControlRowType.DataRow Then btnDel = CType(e.Row.FindControl("btnDelete"),ImageButton) btnDel.Attributes.Add("onclick", "return confirm_delete();") btnDel.CommandArgument = e.Row.RowIndex.ToString 'btnUpd = CType(e.Row.FindControl("btnUpdate"), ImageButton) 'btnUpd.CommandArgument = e.Row.RowIndex.ToString End If

      D 1 Reply Last reply
      0
      • S SamRST

        hi.. use this code in GVList_RowDataBound(...) Dim btnDel As ImageButton, btnUpd As ImageButton, lbexp As Label If e.Row.RowType = DataControlRowType.DataRow Then btnDel = CType(e.Row.FindControl("btnDelete"),ImageButton) btnDel.Attributes.Add("onclick", "return confirm_delete();") btnDel.CommandArgument = e.Row.RowIndex.ToString 'btnUpd = CType(e.Row.FindControl("btnUpdate"), ImageButton) 'btnUpd.CommandArgument = e.Row.RowIndex.ToString End If

        D Offline
        D Offline
        danasegaranea
        wrote on last edited by
        #3

        Thanks for the reply.. You are in the retriving phase. I am asking how to add a server control to the header ?

        _ 1 Reply Last reply
        0
        • D danasegaranea

          Hi All, I am adding one imagebutton in gridview using the "RowDataBound" method. But I could not able to found the onclick/runtat event.. How can i add this one ? ImageButton imgSortAssendingbyId = new ImageButton(); Thanks in Advance Dana

          G Offline
          G Offline
          Gayani Devapriya
          wrote on last edited by
          #4

          Hi Dana, I assume you have already added the ImageButton to the GridView. And here is how you do the rest. The GridView's RowCommand event will fire when you click on that ImageButton in the GridView. That is in your code imgSortAssendingbyId. (This command basically fires for any button’s click event, in the GridView). Example:- protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { Response.Write("You Clicked the Button"); } Thx, Gayani

          1 Reply Last reply
          0
          • D danasegaranea

            Thanks for the reply.. You are in the retriving phase. I am asking how to add a server control to the header ?

            _ Offline
            _ Offline
            _AK_
            wrote on last edited by
            #5

            You can place the Image button in the header template also same way as row databound event gets fired for the headers and footers also.

            Apurva Kaushal

            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