Winforms Combobox SelectedValue - Null

I have a data entry form on which there are several combobox. Each of the combined fields has its own binding source, and it fills correctly when I run the form. However, if I edit the entry in the form and try to transfer the updated selected value from combobox to the database, I get an error message that passes it a NULL value.

This problem seems to happen every time I run the damn line, and I cannot understand why it is not working properly. Basically I am trying to insert a new record into a table, but for some reason it does not pull my selected value. My data entry code is below:

Data.Manager.AddEmployee
 (
   InactiveEmployeeSelected.GUID,
   Convert.ToByte(RoleComboBox.SelectedValue),
   NotesTextBox.Text.Trim(),
   ScheduleTextBox.Text.Trim(),
   ExtensionTextBox.Text.Trim(),
   CodeTextBox.Text.Trim(),
   Convert.ToBoolean(EBApprovedCheckbox.CheckState),
   Convert.ToByte(ApprovalLevelComboBox.SelectedValue),        //pulling null
   Convert.ToBoolean(AssignComtracksCheckbox.CheckState),
   Security.Manager.CurrentUser.GUID,
   DateTime.Today,
   Convert.ToBoolean(IsActiveCheckbox.CheckState)
);

Any help would be greatly appreciated.

+3
3

DropDownStyle DropDown ComboBox? , , SelectedValue , , ComboBox.

, DropDownStyle DropDownList, .

+6
+11

ComboBox DataSource. , ComboBox1.DataSource

+6

Source: https://habr.com/ru/post/1768134/


All Articles