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. Bindingsource C# Adding New Event

Bindingsource C# Adding New Event

Scheduled Pinned Locked Moved C#
csharpcsswpfwcfquestion
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.
  • J Offline
    J Offline
    JensB
    wrote on last edited by
    #1

    Hi, We are using data-binding & typed datasets in our C# .NET 2.0 application (VS2005). We have a bindingsource which has as datasource a dataset and as datamember a datatable. In the form we have a grid which is binded to that bindingsource. We allow new records to be created on the grid. When the users navigates to a new row, the "Adding New" event is raised. We would like to handle this event because we need to set the key of the record to a new Guid. We get as parameter of the "Adding New" function "AddingNewEventArgs e". Then e.NewObject should be set. Well, this doesn't work. After setting the e.NewObject the program crashes. It's like it does not accept my Typed DataRow. Maybe the collection underneath in the Bindingsource accepts another type? Any ideas? Best regards, Jens

    N 1 Reply Last reply
    0
    • J JensB

      Hi, We are using data-binding & typed datasets in our C# .NET 2.0 application (VS2005). We have a bindingsource which has as datasource a dataset and as datamember a datatable. In the form we have a grid which is binded to that bindingsource. We allow new records to be created on the grid. When the users navigates to a new row, the "Adding New" event is raised. We would like to handle this event because we need to set the key of the record to a new Guid. We get as parameter of the "Adding New" function "AddingNewEventArgs e". Then e.NewObject should be set. Well, this doesn't work. After setting the e.NewObject the program crashes. It's like it does not accept my Typed DataRow. Maybe the collection underneath in the Bindingsource accepts another type? Any ideas? Best regards, Jens

      N Offline
      N Offline
      Nader Elshehabi
      wrote on last edited by
      #2

      JensB wrote:

      we need to set the key of the record to a new Guid.

      I did that in several data-bound DataGridViews with no problems. You don't set the e.NewObject to something. Here is how I did it.

      private void MyDataGridView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
      {
      MyDataGridView.Rows[e.RowIndex].Cells[0].Value = Guid.NewGuid().ToString();
      }

      Regards:rose:

      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