In the Form a table(datagrid), combobox's, button "add" and checkbox. Combobox get value from the database. Select something from a list of combobox's, click "add", the data is transferred to the table. Checkbox enables and disables one of combobox's, but the data is still passed in spite of the state of activity. Button to add a SQL query executes with parameters, each parameter respectively, equal to it's combobox's. How to make the combobox when you disable its value has been passed is null, so that one of the columns of table when you click "add" just remained empty, and when you enable it get data of DataSource?
I did this:
SqlParameter param1 = new SqlParameter();
param1.ParameterName = "@name";
if (ComboBox1.Enabled == true)
{
param1.Value = ComboBox1.Text;
param1.SqlDbType = SqlDbType.Text;
}
else
{
param1.Value = " ";
param1.SqlDbType = SqlDbType.Text;
}