I have a combobox that I populate with values from the database. And I have written a code in the SelectedIndexChanged property of the combobox to display the selected item in a label.However, I get this error: 13: Cast from type 'DataRowView' to type 'String' is not valid.VB Code:
Private Sub cbxNationality_SelectedIndexChanged(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles cbxNationality.SelectedIndexChanged Try lblName.Text = cbxNationality.SelectedValue 'lblName.Text = CType(cbxNationality.SelectedValue, String) Catch exp As Exception MessageBox.Show(Err.Number & ": " & exp.Message, Me.Text) End Try End Sub
The commented line too does not work.
Any help will be appreciated.
