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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Datagrid buttons not working

Datagrid buttons not working

Scheduled Pinned Locked Moved ASP.NET
helptutorialquestion
4 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
    chubbysilk
    wrote on last edited by
    #1

    Hello, I am creating a column of buttons for a datagrid which is bound to a dataset. Some columns of the dataset are not being displayed in the datagrid. When I click a button in the datagrid, I would like to retrieve some information from a hidden column of that particular row of the dataset. Does anyone know how to do this? Is there any way to pass this information? Thanks for your help, RC

    J 1 Reply Last reply
    0
    • C chubbysilk

      Hello, I am creating a column of buttons for a datagrid which is bound to a dataset. Some columns of the dataset are not being displayed in the datagrid. When I click a button in the datagrid, I would like to retrieve some information from a hidden column of that particular row of the dataset. Does anyone know how to do this? Is there any way to pass this information? Thanks for your help, RC

      J Offline
      J Offline
      John Kuhn
      wrote on last edited by
      #2

      Something like the following should work:

      Private Sub DataGrid1\_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand
          If (CType(e.CommandSource, Button)).CommandName = "Select" Then
              Dim tc As TableCell = e.Item.Cells(2)
              Dim item As String = tc.Text
          End If
      End Sub
      

      What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.

      C 1 Reply Last reply
      0
      • J John Kuhn

        Something like the following should work:

        Private Sub DataGrid1\_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand
            If (CType(e.CommandSource, Button)).CommandName = "Select" Then
                Dim tc As TableCell = e.Item.Cells(2)
                Dim item As String = tc.Text
            End If
        End Sub
        

        What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.

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

        I actually got it working in a slightly different manner using "e.Item.DataSetIndex". Here is the code I used. public void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e){ Session ["Variable"] = dataSet1.Tables["Data"].Rows[e.Item.DataSetIndex]["ID"].ToString(); } Thanks for your help!!

        J 1 Reply Last reply
        0
        • C chubbysilk

          I actually got it working in a slightly different manner using "e.Item.DataSetIndex". Here is the code I used. public void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e){ Session ["Variable"] = dataSet1.Tables["Data"].Rows[e.Item.DataSetIndex]["ID"].ToString(); } Thanks for your help!!

          J Offline
          J Offline
          John Kuhn
          wrote on last edited by
          #4

          Ah, good one. Much nicer in C#, too. What a piece of work is man, how noble in reason, how infinite in faculties, in form and moving how express and admirable . . . and yet to me, what is this quintessence of dust? -- Hamlet, Act II, Scene ii.

          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