protected void Page_Load(object sender, EventArgs e) { /*Code by Subash*/ if (!IsPostBack) { Employee emp = (Employee)Session["user"]; if (emp.Employee_Role != "Store-Clerk") { Response.Redirect("LoginPage.aspx"); } Suppliers.DataSource = (from o in model.Inventories where o.Quantity < o.Reorder_level select o.Supplier_ID_1).ToList().Distinct(); //(from o in model.Inventories select o.Supplier_ID_1).ToList().Distinct(); Suppliers.DataBind(); ListItem li = new ListItem("Select the supplier", "-1"); Suppliers.Items.Insert(0, li); btn_GenPurchaseOrder.Enabled = false; } }
//public void LoadGrid() //{ // using (var ctx = new ProductMNEntities()) // { // var domain = new ProductDomain(ctx); // var list = domain.GetAll().ToList(); // ProductGrid.DataSource = list; // ProductGrid.DataBind(); // } //} public void SetDropDownList() { using (var ctx = new ProductMNEntities()) { var query = ctx.Suppliers.Select(s => new DropDownListVMs() { Text = s.CompanyName, Value = s.SupplierID.ToString() }).ToList(); query.Insert(0, new DropDownListVMs() { Text = "---Any---", Value = "" }); Suppliers.DataTextField = "Text"; Suppliers.DataValueField = "Value"; Suppliers.DataSource = query; Suppliers.DataBind(); } }