protected void FindTerritories_Click(object sender, EventArgs e) { if (RegionList.SelectedIndex == 0) { errormsgs.Add("Select a region to obtain territories."); LoadMessageDisplay(errormsgs, "alert alert-info"); TerritoryList.DataSource = null; TerritoryList.DataBind(); EmployeesGridViewV4.DataSource = null; EmployeesGridViewV4.DataBind(); } else { try { TerritoryController sysmgr = new TerritoryController(); List <Territory> info = sysmgr.Territory_GetByRegion(int.Parse(RegionList.SelectedValue)); if (info.Count == 0) { errormsgs.Add("No data found for the region"); LoadMessageDisplay(errormsgs, "alert alert-info"); } else { info.Sort((x, y) => x.TerritoryDescription.CompareTo(y.TerritoryDescription)); //Second Dropdown list drill down TerritoryList.DataSource = info; TerritoryList.DataTextField = nameof(Territory.TerritoryDescription); TerritoryList.DataValueField = nameof(Territory.TerritoryID); TerritoryList.DataBind(); TerritoryList.Items.Insert(0, "select...."); //GridView EmployeesGridViewV4.DataSource = null; EmployeesGridViewV4.DataBind(); } } catch (Exception ex) { errormsgs.Add(GetInnerException(ex).ToString()); LoadMessageDisplay(errormsgs, "alert alert-danger"); } } }
protected void FindEmployees_Click(object sender, EventArgs e) { if (TerritoryList.SelectedIndex == 0) { errormsgs.Add("Select a territory to view the territory employees."); LoadMessageDisplay(errormsgs, "alert alert-info"); EmployeesGridViewV4.DataSource = null; EmployeesGridViewV4.DataBind(); } else { try { EmployeeController sysmgr = new EmployeeController(); List <EmployeeOfTerritory> info = sysmgr.Employee_GetByTerritory(TerritoryList.SelectedValue); if (info.Count == 0) { errormsgs.Add("No data found for the territory"); LoadMessageDisplay(errormsgs, "alert alert-info"); } else { info.Sort((x, y) => x.FirstName.CompareTo(y.FullName)); //GridView EmployeesGridViewV4.DataSource = info; EmployeesGridViewV4.DataBind(); } } catch (Exception ex) { errormsgs.Add(GetInnerException(ex).ToString()); LoadMessageDisplay(errormsgs, "alert alert-danger"); } } }