Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //Setting the department dropdowns
                _departments = _departmentDao.GetDepartments();
                foreach (Department d in _departments)
                {
                    ListItem l = new ListItem(d.Name, _departmentDao.GetDepartmentId(d.Name).ToString());
                    DrpDepartment.Items.Add(l);
                }
                DrpDepartment.SelectedIndex = 0;

                //Getting the item id from session from the admin form page
                _itemId = Convert.ToInt32(Session["ItemId"]);
                if (Session["Item"] is Item item)
                {
                    //If it isn't null, display item properties to user
                    TxtDescription.Text = item.Description;
                    TxtName.Text        = item.Name;
                    TxtPrice.Text       = item.Price.ToString();
                    //DrpDepartment.SelectedIndex = item.DepartmentId;

                    //Setting pin location on map
                    hidFinalCoords.Value = item.Location;
                    SetPin(item.Location);
                }
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //Setting up objects as needed
                var depDao =
                    new DepartmentDao(Properties.Settings.Default.conString);
                var dept = depDao.GetDepartments();

                //Adding departments to a list using a foreach loop
                foreach (Department d in dept)
                {
                    ListItem l = new ListItem(d.Name,
                                              depDao.GetDepartmentId(d.Name).ToString());
                    drpDepartment.Items.Add(l);
                }

                //Setting the dropdown to the list of departments as well as selecting
                //a default value from the start
                drpDepartment.DataTextField  = "Name";
                drpDepartment.DataValueField = "Id";
                drpDepartment.DataSource     = dept;
                drpDepartment.DataBind();
                drpDepartment.SelectedIndex = 0;
                drpDepartment.SelectedIndex = 0;
            }
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Setting up Dao as well as the list of all departments
            if (!IsPostBack)
            {
                var depDao = new DepartmentDao(Properties.Settings.Default.conString);
                var dept   = depDao.GetDepartments();
                dept = depDao.GetDepartments();

                //Setting the dropdown to the list of departments as well as selecting
                //a default value from the start
                foreach (Department d in dept)
                {
                    ListItem l = new ListItem(d.Name, depDao.GetDepartmentId(d.Name).ToString());
                    drpDepartment.Items.Add(l);
                }

                drpDepartment.SelectedIndex = 0;
            }
        }