Issue with strongly typed dataset and 2 buttons

o9z

Member
Joined
Aug 8, 2007
Messages
6
Programming Experience
Beginner
Ok, using my strongly typed dataset, everything worked fine. There is one piece of functionality that I would like to change though.

Currently I have 2 buttons.

btnSave handles the saving for all of my data entry textboxes. Once all data entry is done, it saves the data entry to a SQL table, and then executes a query to populate a DataGridView. This works fine.

the 2nd button is called btnSaveGroup
Once the DGV is populated with data, the user can go in and edit the value in the DGV if needed and btnSaveGroup will push these changes back to the SQL table.

All of this needs to happen on 2 different buttons.
The only functionality that needs to happen in regards to the DGV is btnSave will originally populate the DGV and btnSaveGroup will save any changes to the DGV back to the SQL table.

This all works fine IF I first click btnSave and THEN click btnSaveGroup if changes are made. The problem with this is I use a binding navigator and have it setup to populate the DGV anytime a new record is pulled up. If I click btnSaveGroup after I make a change to the DGV, changes WILL NOT save unless I click btnSave and THEN btnSaveGroup.

THe error I get if I just try to click btnSaveGroup is
Value cannot be null. Parameter name Data Table

here is the code I have on the 2 buttons for this

VB.NET:
   Dim GroupDataAdapter As New dsOneTableAdapters.taGroupData
   Dim GroupData As dsOne.t_groupdataDataTable

   Private Sub bnBtnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bnBtnSave.Click
        GroupData = GroupDataAdapter.GetDataByKsID(txtKsId.Text)
        GroupDataList.DataSource = GroupData
   End Sub

   Private Sub btnSaveGroup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveGroup.Click
        GroupDataAdapter.Update(GroupData)
   End Sub

I want to be able to use BOTH buttons to do this, since after originally saving the dataentry, the btnSave will be clicked, and then bnBtnSaveGroup will be clicked to save DGV changes, but I also want to be able to use JUST btnSaveGroup if any changes are made to the DGv when browsing records with the binding navigator. Does this make sense? Do I just need to fill my dataset in the btnSaveGroup click event too?
 
Back
Top