I have a problem with a combobox and no page on the Internet has been able to help me so far. So I hope that one of you can.
I have a form (with information about clients) with textboxes binded to a dataview. One of the columns in the dataview contains a number that tells me what kind of client it is. I don't my users want that my users have to fill in a number in a textbox, but I want them to choose a item from a combobox. De selected value should be the value that is actually saved in the database.
This is my code:
Dim cmd As New SqlCommand Dim dr As SqlDataReader VerbindingMaken() cmd.Connection = cnnVraagbaak cmd.CommandType = CommandType.StoredProcedure cmd.CommandText = "relatie.proc_OpvragenRelatiesoort" daRelatie.SelectCommand = cmd daRelatie.Fill(dsRelatie, "Relatiesoort") cbo.DataSource = dsRelatie.Tables("Relatiesoort") cbo.ValueMember = dsRelatie.Tables("Relatiesoort").Columns(0).ToStri ng cbo.DisplayMember = dsRelatie.Tables("Relatiesoort").Columns(1).ToStri ng cbo.DataBindings.Add("SelectedValue", dsRelatie.Tables("Relaties"), "Relatiesoort")
De Datasource is the information in my combobox. With Databindings I'm trying to bind it to my dataset (or view, that doesn't work either) with clients. Every time I get a NullReferenceExeption. The moment I remove the line cbo.DataSource = dsRelatie.Tables("Relatiesoort"), I don't get an error, but it doesn't work either.
That dataset is filled (I've checked) and also the derived view. The column Relatiesoort exists.
What do I have to do to make it possible for my users to choose an item from a combobox and save the selected value to the underlying dataset?