1
Answer

Adding items to comboBox at runtime C# windows application

Hanan Masood

Hanan Masood

10y
777
1
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)