private void GetPrograms() { _programsList.Clear(); ddlProgram.DataSource = null; try { var query = _context.usp_QT_LightingStudy_GetPrograms(Application).ToList(); if (!query.Any()) { return; } _programsList.Add(""); foreach (usp_QT_LightingStudy_GetPrograms_Result item in query) { _programsList.Add(item.Program); } ddlProgram.DataSource = _programsList; } catch (Exception ex) { string error = (ex.InnerException != null) ? ex.InnerException.Message : ex.Message; MessageBox.Show(string.Format("Failed to return Lighting Programs. Try refreshing. {0}", error), "Error at GetProgramNumbers()"); } }