Results 1 to 4 of 4

Thread: help with child table newrow in dataset

  1. #1
    ghardy is offline VB.NET Forum Newbie
    .NET Framework
    .NET 2.0
    Join Date
    Mar 2010
    Posts
    20
    Reputation
    41

    Question help with child table newrow in dataset

    hi all,

    i have a dataset in my application (vb.net2008) that has a parent table with some child tables linked with a relationship. i would like to be able to open the form in "new" mode, and allow the user to create the whole dataset, and hit the save button once, but this isn't working for me.

    what happens is i have a link button that allows them to add "labor resources" to the child grid, but when i try to do the addnewitemrow, it says "no position at row 0." i assume this is because the parent record hasn't been saved, and therefore, does not yet have a rowhandle.

    AddLaborRow(dsSpread.Spread.Rows(0), field, field, ....)

    is there a trick to doing this? right now, i open the form, let them fill in the parent table info, then force them to save it before enabling the child grid and allow additions there. this seems cheesy to me though.

    thanks!
    Last edited by ghardy; 03-19-2010 at 10:47 AM.

  2. #2
    jmcilhinney's Avatar
    jmcilhinney is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    11,335
    Reputation
    1543
    If you want to add child records then there must be a parent record, plain and simple. The only requirement is that there's a parent record in the DataSet though. You can't add child records to the DataSet until you've added the parent record to the DataSet and you can save child records to the database until you've added the parent record to the database. They are two independent steps.

  3. #3
    cjard's Avatar
    cjard is offline VB.NET Forum All-Mighty
    .NET Framework
    .NET 4.0
    Join Date
    Apr 2006
    Posts
    7,027
    Reputation
    1705

  4. #4
    cjard's Avatar
    cjard is offline VB.NET Forum All-Mighty
    .NET Framework
    .NET 4.0
    Join Date
    Apr 2006
    Posts
    7,027
    Reputation
    1705
    ps; if that thread doesnt make sense:

    Unlink the (add new ) on the binding navigator, and control the addnew yourself

    call Parent.AddNew() then immediately Parent.EndEdit()

    Then do the same for the child

    Then allow the user to edit the data

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking