Hi
Below I created a separate class where I select data from my database
public ArrayList CognosComboBox()
{
dbConnection();
string sqlCBO = "SELECT DISTINCT courseCode FROM Courses;";
dbCmd = new OleDbCommand(sqlCBO, dbConn);
OleDbDataReader reader = dbCmd.ExecuteReader();
ArrayList myList = new ArrayList();
myList.Add("Choose course");
while (reader.Read())
{
myList.Add(reader[0].ToString());
}
reader.Close();
dbConn.Close();
return myList;
}
Below is the back code
N.B cboCourses
public void populateCombo()
{
DataCls dtClass = new DataCls();
cboCourses.DataSource = dtClass.CognosComboBox();
cboCourses.DataBind();
}
Then you can call populateCombo() any where you want even on Page_Load()
Hope it helps...