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. how to determine which row is selected by cliking one button in a gridview?

how to determine which row is selected by cliking one button in a gridview?

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestion
3 Posts 3 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.
  • S Offline
    S Offline
    Seraph_summer
    wrote on last edited by
    #1

    I add one button for each row in a gridview, then some process will be carried out by cliking the button, first of all, the selected row should be identified by clicking the button, but I do not know which function should be used? thank you for your help in advance!

    A 1 Reply Last reply
    0
    • S Seraph_summer

      I add one button for each row in a gridview, then some process will be carried out by cliking the button, first of all, the selected row should be identified by clicking the button, but I do not know which function should be used? thank you for your help in advance!

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      Use GridView RowCommand Event http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcommand.aspx[^]

      Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

      I 1 Reply Last reply
      0
      • A Abhijit Jana

        Use GridView RowCommand Event http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowcommand.aspx[^]

        Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

        I Offline
        I Offline
        Inderjeet Kaur
        wrote on last edited by
        #3

        You can use RowCommandEvent like this. e.Command name give thename of your button you gave in aspx. Now do whatever you want to do. You can also use RowdataBound event. protected void gvCardFeesRReport_RowCommand(object sender, GridViewCommandEventArgs e) { try { switch (e.CommandName) { case "First": gvCardFeesRReport.PageIndex = 0; break; case "Prev": if (gvCardFeesRReport.PageIndex > 0) gvCardFeesRReport.PageIndex = gvCardFeesRReport.PageIndex - 1; break; case "Next": if (gvCardFeesRReport.PageIndex < gvCardFeesRReport.PageCount - 1) gvCardFeesRReport.PageIndex = gvCardFeesRReport.PageIndex + 1; break; case "Last": gvCardFeesRReport.PageIndex = gvCardFeesRReport.PageCount - 1; break; } } catch (System.Threading.ThreadAbortException) { }

        Inderjeet Kaur Sr. Software Engg

        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