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. .NET (Core and Framework)
  4. Problem with Strong Typed Dataset with DataGridView

Problem with Strong Typed Dataset with DataGridView

Scheduled Pinned Locked Moved .NET (Core and Framework)
helpquestion
2 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.
  • K Offline
    K Offline
    kakarato
    wrote on last edited by
    #1

    1.I create a strong typed dataset. 2.I bound the table from the strong Typed dataset to a DataGridView. 3.User Click on a row and press "Select" button. I can just cast the selected row with code below: this.returnedRow = (TypedDS.MasterGroupSearchRow)this.dgvMasterContract.CurrentRow.DataBoundItem; 4.At this moment the this.dgvMasterContract.CurrentRow.DataBoundItem is (TypedDS.MasterGroupSearchRow) But if After Click on the column header .. problem come out ... this.dgvMasterContract.CurrentRow.DataBoundItem will become System.Data.DataRow. So code below will fail .. this.returnedRow = (TypedDS.MasterGroupSearchRow)this.dgvMasterContract.CurrentRow.DataBoundItem; Is there anyway to solve this problem ? or is there anyway to preserve it original typed row ?

    T 1 Reply Last reply
    0
    • K kakarato

      1.I create a strong typed dataset. 2.I bound the table from the strong Typed dataset to a DataGridView. 3.User Click on a row and press "Select" button. I can just cast the selected row with code below: this.returnedRow = (TypedDS.MasterGroupSearchRow)this.dgvMasterContract.CurrentRow.DataBoundItem; 4.At this moment the this.dgvMasterContract.CurrentRow.DataBoundItem is (TypedDS.MasterGroupSearchRow) But if After Click on the column header .. problem come out ... this.dgvMasterContract.CurrentRow.DataBoundItem will become System.Data.DataRow. So code below will fail .. this.returnedRow = (TypedDS.MasterGroupSearchRow)this.dgvMasterContract.CurrentRow.DataBoundItem; Is there anyway to solve this problem ? or is there anyway to preserve it original typed row ?

      T Offline
      T Offline
      Tristan Rhodes
      wrote on last edited by
      #2

      Check the type before you process the OnClick event? Is this a web grid view or a winform gridview?

      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