/// <summary> /// handles the loading of the module setting for this /// control /// </summary> public override void LoadSettings() { try { if (!IsPostBack) { using (SelectedHotelsEntities db = new SelectedHotelsEntities()) { DropDownListDepartments.DataSource = db.Departments.OrderBy(s => s.Name).ToList(); DropDownListDepartments.DataBind(); DropDownListMerchantCategories.DataSource = db.MerchantCategories.ToList().OrderBy(s => s.FullName); DropDownListMerchantCategories.DataBind(); object setting = Settings["department"]; if (setting != null) { int departmentId = Convert.ToInt32(setting); DropDownListDepartments.SelectedValue = departmentId.ToString(); } setting = Settings["merchantcategory"]; if (setting != null) { int merchantCategoryId = Convert.ToInt32(setting); DropDownListMerchantCategories.SelectedValue = merchantCategoryId.ToString(); } } } } catch (Exception ex) { Exceptions.ProcessModuleLoadException(this, ex); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { SqlConnection Conn = new SqlConnection("Data Source = (LocalDB)\\MSSQLLocalDB; AttachDbFilename = \"C:\\Users\\anthony\\Documents\\~Docs\\ws\\VS2015\\Projects\\CIS 2284\\DatabaseDemo\\DatabaseDemo\\App_Data\\DemoDB.mdf\"; Integrated Security = True"); SqlCommand cmd = new SqlCommand("SELECT * FROM Department", Conn); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); DropDownListDepartments.DataSource = ds; DropDownListDepartments.DataBind(); } }