Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Save data in ComboBox in a DataGrid to the database
Message
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
00867482
Message ID:
00869630
Views:
22
In case anyone is interested I added the following code to the Public Class DataGridComboBoxColumn
(see initial entry for more info):
Public Class DataGridComboBoxColumn

    Public Event SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs)

    Private Sub ColumnComboBox_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) _
                                                          Handles ColumnComboBox.SelectedValueChanged
            RaiseEvent SelectedValueChanged(sender, e)
    End Sub

End Class
Now when the Selected value of the comboBox changes, I raise the SelectedValueChanged event.
On my form where the grid resides that I am using the dropdown combobox, I do the following:
Private Sub cboDataGrid_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) _
                                                         Handles cboDataGrid.SelectedValueChanged
        '-----------------------------------------------------------
        ' When the values changes in the combo box for priority, we 
        ' populate the current datarow with that value
        '-----------------------------------------------------------
        Try
            Dim strPriorityID As String
            Dim cm As CurrencyManager = _
                            CType(Me.dgFileInfo.BindingContext(dgFileInfo.DataSource), CurrencyManager)

            If Not (Me.cboDataGrid.ColumnComboBox.SelectedValue Is Nothing) Then
                strPriorityID = Me.cboDataGrid.ColumnComboBox.SelectedValue.ToString

                Dim pk As New Guid(strPriorityID)

                Dim row As DataRow = CType(cm.Current, DataRowView).Row
                row("fk_PriorityID") = pk

            End If

        Catch ex As Exception
            m_Error.ErrorMessage(ex.Message, "frmInformation::cboDataGrid_SelectedValueChanged")
        End Try
End Sub
I am not sure if this is the "correct" way to do this, but at least now I can save information that is entered using the combobox.

Thanks,

Vic
Previous
Reply
Map
View

Click here to load this message in the networking platform