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. General Programming
  3. C#
  4. DataGridView... Deleting/finding a row from/in the underlying DataSource (DataTable) Ideas anyone?

DataGridView... Deleting/finding a row from/in the underlying DataSource (DataTable) Ideas anyone?

Scheduled Pinned Locked Moved C#
databasequestionhelp
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.
  • B Offline
    B Offline
    blakey404
    wrote on last edited by
    #1

    Hello all, I am having an annoying little problem with accessing an underlying row in a datatable which is being displayed in a datagridview. I need to get hold of the ID column in the DataSource, however it is one of the columns I am not displaying to the user in the DataGridView. I can then fire a stored procedure to delete the correct row from the SQL database. How do i access the row which is currently selected in the DataSource? I know about SelectedRows[] but it doesnt contain my ID column. Thanks in advance...

    modified on Tuesday, April 22, 2008 10:18 AM

    B 1 Reply Last reply
    0
    • B blakey404

      Hello all, I am having an annoying little problem with accessing an underlying row in a datatable which is being displayed in a datagridview. I need to get hold of the ID column in the DataSource, however it is one of the columns I am not displaying to the user in the DataGridView. I can then fire a stored procedure to delete the correct row from the SQL database. How do i access the row which is currently selected in the DataSource? I know about SelectedRows[] but it doesnt contain my ID column. Thanks in advance...

      modified on Tuesday, April 22, 2008 10:18 AM

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      when you select row from datagridview then save ID value in one label,use labels value to delete your data based on last selected ID on datagridview.


      I Love T-SQL

      B 1 Reply Last reply
      0
      • B Blue_Boy

        when you select row from datagridview then save ID value in one label,use labels value to delete your data based on last selected ID on datagridview.


        I Love T-SQL

        B Offline
        B Offline
        blakey404
        wrote on last edited by
        #3

        Could do but thats a big hack i think there has to be a nicer way

        B 1 Reply Last reply
        0
        • B blakey404

          Could do but thats a big hack i think there has to be a nicer way

          B Offline
          B Offline
          blakey404
          wrote on last edited by
          #4

          GOTCHA!!! DataRow bishyBashy = ((DataRowView)(this.dataGridViewExistingSecurityLevels.SelectedRows[0].DataBoundItem)).Row;

          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