private void BindSupplierDropDown() { InventoryPurchasingController controller = new InventoryPurchasingController(); SupplierDropDownList.DataSource = controller.ListAllSuppliers(); SupplierDropDownList.DataTextField = "CompanyName"; SupplierDropDownList.DataValueField = "SupplierID"; SupplierDropDownList.DataBind(); SupplierDropDownList.Items.Insert(0, new ListItem("[Select a supplier]", "-1")); }
private void PopulateSupplierDropDown() { InventoryPurchasingController controller = new InventoryPurchasingController(); List <Supplier> data = controller.ListAllSuppliers(); SupplierDropDown.DataSource = data; SupplierDropDown.DataTextField = "CompanyName"; SupplierDropDown.DataValueField = "SupplierID"; SupplierDropDown.DataBind(); SupplierDropDown.Items.Insert(0, "[select a supplier]"); }
private void PopulateSupplierDropDown() { InventoryPurchasingController controller = new InventoryPurchasingController(); List <Supplier> suppliers = controller.ListAllSuppliers(); Supplier.DataSource = suppliers; Supplier.DataTextField = "CompanyName"; Supplier.DataValueField = "SupplierID"; Supplier.DataBind(); // Let's insert a couple of options at the top of the drop-down Supplier.Items.Insert(0, new ListItem("[select a supplier]")); Supplier.Items.Insert(1, new ListItem("[no supplier]", "")); // because Product.SupplierID is nullable }