private void PopulateCategoryDropDown() { InventoryPurchasingController controller = new InventoryPurchasingController(); List <Category> data = controller.ListAllCategories(); CategoryDropDown.DataSource = data; CategoryDropDown.DataTextField = "CategoryName"; CategoryDropDown.DataValueField = "CategoryID"; CategoryDropDown.DataBind(); CategoryDropDown.Items.Insert(0, "[select a Category]"); }
private void PopulateCategoryDropdown() { // Populate Category drop-down InventoryPurchasingController controller = new InventoryPurchasingController(); List <Category> categories = controller.ListAllCategories(); CurrentCategories.DataSource = categories; CurrentCategories.DataTextField = "CategoryName"; CurrentCategories.DataValueField = "CategoryID"; CurrentCategories.DataBind(); CurrentCategories.Items.Insert(0, "[select a category]"); }
private void PopulateCategoryDropDown() { InventoryPurchasingController controller = new InventoryPurchasingController(); List <Category> categories = controller.ListAllCategories(); Category.DataSource = categories; Category.DataTextField = "CategoryName"; Category.DataValueField = "CategoryID"; Category.DataBind(); // Let's insert a couple of options at the top of the drop-down Category.Items.Insert(0, new ListItem("[select a category]")); Category.Items.Insert(1, new ListItem("[no category]", "")); // because Product.CategoryID is nullable }