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. Geting the Row count in response to RowDeleted

Geting the Row count in response to RowDeleted

Scheduled Pinned Locked Moved C#
csharpcssquestionannouncement
3 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.
  • S Offline
    S Offline
    stephen woolhead
    wrote on last edited by
    #1

    I am sure that .Net was sent to drive us all insane. I have a data grid bound to a datatable in a dataset. I have a label that displays the number of items in the grid, or shall we say it should ;-) I wanted to update the row count in response to RowChanged and RowDeleted, just set the label equal to DataTable.Rows.Count. But no, thats not updated until after the event has fired. Are there any events in DataTable, DataSet, DataView or anything else that fires _after_ the row count has been updated? Looks like I have to put some convulted logic in there to work out what the user is doing :-( Thanks Stephen.

    S 1 Reply Last reply
    0
    • S stephen woolhead

      I am sure that .Net was sent to drive us all insane. I have a data grid bound to a datatable in a dataset. I have a label that displays the number of items in the grid, or shall we say it should ;-) I wanted to update the row count in response to RowChanged and RowDeleted, just set the label equal to DataTable.Rows.Count. But no, thats not updated until after the event has fired. Are there any events in DataTable, DataSet, DataView or anything else that fires _after_ the row count has been updated? Looks like I have to put some convulted logic in there to work out what the user is doing :-( Thanks Stephen.

      S Offline
      S Offline
      Stephane Rodriguez
      wrote on last edited by
      #2

      The order of events being triggered are as follows : - RowChanging - RecordStateChanged - RowChanged - and only then the Rows.Count value is updated (!) ( this.Rows.ArrayAdd(row); ) Since DataRowCollection (what you get with this.Rows) is an internal class, and on the other hand the collection itself (ArrayList) doesn't trigger any event when objects are added, updated or removed, I am afraid you are a bit bound to rely on code like this : - make sure to subscribe for all RowChanged events. - make sure to read the DataRawChangedEventArgs .Action property passed along with it, and check for one of these actions {Add, Change, Commit, Delete, Nothing, Rollback}. - then, from the current Row Count value, and this action, just try to guess the final Row Count value. (*) - alternatively to (*), create a short life timer in your RowChanged event handler and let it go. Then get the actual Row Count value when the timer signals.

      S 1 Reply Last reply
      0
      • S Stephane Rodriguez

        The order of events being triggered are as follows : - RowChanging - RecordStateChanged - RowChanged - and only then the Rows.Count value is updated (!) ( this.Rows.ArrayAdd(row); ) Since DataRowCollection (what you get with this.Rows) is an internal class, and on the other hand the collection itself (ArrayList) doesn't trigger any event when objects are added, updated or removed, I am afraid you are a bit bound to rely on code like this : - make sure to subscribe for all RowChanged events. - make sure to read the DataRawChangedEventArgs .Action property passed along with it, and check for one of these actions {Add, Change, Commit, Delete, Nothing, Rollback}. - then, from the current Row Count value, and this action, just try to guess the final Row Count value. (*) - alternatively to (*), create a short life timer in your RowChanged event handler and let it go. Then get the actual Row Count value when the timer signals.

        S Offline
        S Offline
        stephen woolhead
        wrote on last edited by
        #3

        Thanks for that, I had come to the same conclusion, but it's good to hear it from someone else. I wounder if any of this behaviour has changed in V1.1 of the framework? Stephen.

        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