How to check selected combobox value is null? I am filling comboboxes with these functions:
string sql = "select employee from db_company";
SqlDataReader dr = Db.loadData(sql);
if(cbox.Items.Count == 0)
{
while (dr.Read())
{
cbox.Items.Add(dr[0].ToString());
}
}
In another class, loadData function is:
public SqlDataReader loadData(string sql, params object[] parameters)
{
SqlCommand command = new SqlCommand(sql, Db);
for (int i = 0; i < parameters.Length;)
{
command.Parameters.AddWithValue(parameters[i++] as string, parameters[i++]);
}
SqlDataReader dr = command.ExecuteReader();
return dr;
}
and I'm trying to check with this function:
public bool nullCheck(params object[] parameters)
{
bool check = true;
for(int i = 0; i < parameters.Length; i++)
{
if (parameters[i] == null)
check = false;
}
return check;
}
And when I pass combobox or textBox values as parameters to nullCheck(), the debug says for comboBox,
System.Windows.Forms.ComboBox, Items.Count 14
I'm trying to figure out how can I handle this, I tried some ways, for example showing the value of combobox, however messagebox shows null.