Question detail view : comboBox value is not getting into the dataset before update

wcswanson

New member
Joined
Feb 14, 2013
Messages
4
Programming Experience
10+
The dataset is missing the JobSiteID(required field) but it exists in the Winforms combobox.
The following code fails to get thecombobox.SelectedValue into the dataset.

VB.NET:
 Private Sub EstimatingSheetBindingNavigatorSaveItem_Click(sender As System.Object, e As System.EventArgs) 
        Handles EstimatingSheetBindingNavigatorSaveItem.Click,  btnSave.Click       


        Dim rc As Integer = -1
        Dim Msg As String = ""


        Me.Validate()
        Me.EstimatingSheetBindingSource.EndEdit()
    
        Try
            rc = Me.TableAdapterManager.UpdateAll(Me.DsEstimator3)
        Catch ex As Exception
            Msg = ex.Message.ToString
        End Try


        If Msg = "" Then
            lblUpdate.Text = "Rows updated: " & rc.ToString
        Else
            lblUpdate.Text = Msg
        End If


    End Sub

I have this similar code on a similar form and it works. I have found 2 work arounds.

  1. Hard code the value into the dataset before doing the UpdateAll.

VB.NET:
  Dim rRow As Integer = EstimatingSheetBindingSource.Position


        If IsDBNull(DsEstimator3.EstimatingSheet.Rows(rRow)("JobSiteID")) Then
            DsEstimator3.EstimatingSheet.Rows(rRow)("JobSiteID") = VJobSiteComboBox.SelectedValue
        End If

  1. 2.Make the user click in the combobox before the update.
    I have tried to find the code to click the combobox for the user but I have not been able to find the right combination.


How can I make sure the data from thecombobox is injected into the dataset before updating?


 
Top Bottom