Win Form 2 Data Binding

Posts   
 
    
ftuttle
User
Posts: 40
Joined: 10-Dec-2006
# Posted on: 14-Mar-2007 18:50:30   

I have several forms that I would like to data bind to Entity Collections. I use a list box that displays all of the records (by Name description), the user will click on an item in the list box and the various controls (not a grid) on this form will populate with the selected record.

I have buttons for New, Cancel, Save and Delete.

I am having difficulty setting this up to work this wasy. Is there an example project I can see that can help me with this using LLBL Gen Pro.

I also read that the Entity Collection AddNew does not automatically navigate to the new empty record for a Data Bound form. How can I set the bound form to the new empty record?

thanks

ftuttle
User
Posts: 40
Joined: 10-Dec-2006
# Posted on: 14-Mar-2007 23:57:03   

I got past some of my issues however the Deleting of records does not get propagated to the DB.

The user will select an Item in a List Control. The data for that item is displayed on the form. If the user clicks the delete button, the data is removed from the list box and the form no longer displays the data. All of this works fine. And I am trying in the code below to save the Entity Collection. If I close the form and then re0-open the form, the data I deleted appears - it was not deleted.

What do I need to do in code that I am not doing?

Private Sub BtnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDelete.Click

    EntityQual.RemoveAt(ListNames.SelectedIndex)

    SaveQualEntity()

End Sub

Private Sub SaveQualEntity()
    Try
        adapter.SaveEntityCollection(EntityQual, True)

        BindList()

    Catch ex As Exception

    End Try
End Sub
bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 15-Mar-2007 01:55:54   

Saving an collection with a removed entity will not delete the entity from the database. To delete the entity you should call the delete for the entity when the delete button is pressed and remove it from the collection.