Datagridview dropdownbox value changed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Danny M

    #1

    Datagridview dropdownbox value changed

    When i change the value in the dropdownbox.
    The value changes.
    When i check the datatable the value has changed
    But when i want to save it to the database the record didnt got a
    changed flag
    When i do dtTest = dtData.getchang es then dtTest is nothing ???
    But still the value in the datatable has the right value, but because
    it didnt have a change flag it isnt saved to the database???

    What i am doing wrong??

    With _ColumnPositie
    .HeaderText = "Positie"
    .Width = 120
    .DataSource = g_cDatabase.dtP ositie
    .DataPropertyNa me = "PlayerPosi tie"
    .DisplayMember = "PositieOmschri jving"
    .ValueMember = "Positie"
    .Name = "cboPositie "
    End With
    dgvPlayers.Colu mns.Insert(3, _ColumnPositie)


    mine update functie

    Public Sub DBUpdate(ByVal dtData As DataTable, ByVal sTabelNaam As
    String)

    Dim daUpdate As New SqlDataAdapter( )
    daUpdate.Select Command = New SqlCommand("Sel ect * from " &
    sTabelNaam, _SQLConn)
    Dim cbUpdate As SqlCommandBuild er = New
    SqlCommandBuild er(daUpdate)

    Dim dtTest As DataTable
    dtTest = dtData.GetChang es

    cbUpdate.GetDel eteCommand()
    cbUpdate.GetIns ertCommand()
    cbUpdate.GetUpd ateCommand()

    daUpdate.Update (dtData)
    dtData.AcceptCh anges()
    End Sub

    and if a value changes:

    Private Sub dgvPlayers_Cell ValueChanged(By Val sender As Object, ByVal e
    As System.Windows. Forms.DataGridV iewCellEventArg s) Handles
    dgvPlayers.Cell ValueChanged

    If dgvPlayers.Curr entCell.ColumnI ndex = 3 Then
    g_cDatabase.DBU pdate(dgvPlayer s.DataSource, "T_Players" )
    End If
    end sub

Working...