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); } } }
protected void Page_Load(object sender, EventArgs e) { //Getting the item id from session from the admin form page _itemId = Convert.ToInt32(Session["ItemId"]); if (!IsPostBack) { //Getting the item id from session from the admin form page _itemId = Convert.ToInt32(Session["ItemId"]); //Setting the dropdown to all the departments from the Departments table _departments = _departmentDao.GetDepartments(); DrpDepartment.DataSource = _departments; DrpDepartment.DataTextField = "Name"; DrpDepartment.DataValueField = "Id"; DrpDepartment.DataBind(); DrpDepartment.SelectedIndex = 0; 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(); //Setting pin location on map SetPin(item.Location); hidFinalCoords.Value = item.Location; } } }
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; } }
protected void Page_Load(object sender, EventArgs e) { //Getting a list of all departments and items in the database _departments = _departmentDao.GetDepartments(); _items = _itemDao.GetItems(); if (!IsPostBack) { } }
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; } }
protected void Page_Load(object sender, EventArgs e) { //Getting a list of all departments and items in the database _departments = _departmentDao.GetDepartments(); _items = _itemDao.GetItems(); if (!IsPostBack) { //Setting the DropDown to only the items that fit the search criteria DrpSearch.DataTextField = "Name"; DrpSearch.DataValueField = "Name"; DrpSearch.DataSource = _items; DrpSearch.DataBind(); DrpSearch.SelectedIndex = 0; } }