Hanan Masood

Hanan Masood

  • NA
  • 2
  • 2.1k

Adding items to comboBox at runtime C# windows application

Jul 10 2014 7:19 AM
I am reading values from database and assigning these values to combo but it didn't assign
try
{
objCls.objSqlCmd = new SqlCommand();
objCls.objSqlCmd.CommandType = CommandType.Text;
objCls.objSqlCmd.CommandText = "SELECT * FROM attributeValue WHERE attributeCode='" + attributeCode + "'";
objCls.objSqlCmd.Connection = clsObjects.objSqlCon;
clsObjects.objSqlDr = objCls.objSqlCmd.ExecuteReader();
while (clsObjects.objSqlDr.Read())
{
cmbDropDown.Items.Add(clsObjects.objSqlDr["v1"].ToString());
cmbDropDown.Items.Add(clsObjects.objSqlDr["v2"].ToString());
cmbDropDown.Items.Add(clsObjects.objSqlDr["v3"].ToString());
}
clsObjects.objSqlDr.Close();
}
catch (Exception ex)
{
clsFunction.CathExeption(ex);
}
 

Answers (1)