protected void LoadWarehouseAgents() { string[] sExcludedAgents = { }; int iInternal = Convert.ToInt32(Session["Internal"]); DataTable dtAgentsWithWarehouse = q.AgentsWithWarehouses(iInternal == 1 ? false : true); ddlAgentsWithWarehouse.DataTextField = "Distributor"; ddlAgentsWithWarehouse.DataValueField = "MGMAgentNo"; if (WebConfigurationManager.AppSettings["ExcludeAgentCode"] != null) { sExcludedAgents = WebConfigurationManager.AppSettings["ExcludeAgentCode"].ToString().Split(';'); } foreach (string sExclude in sExcludedAgents) { if (sExclude != "") { dtAgentsWithWarehouse = dtAgentsWithWarehouse.AsEnumerable().Select(r => r).Where(d => Convert.ToInt32(d["MGMAgentNo"]) != Convert.ToInt32(sExclude)).Select(v => v).CopyToDataTable(); } } //remove MGM dtAgentsWithWarehouse = dtAgentsWithWarehouse.AsEnumerable().Select(r => r).Where(d => Convert.ToInt32(d["MGMAgentNo"]) != 0).Select(v => v).CopyToDataTable(); DataRow drAgentWarehouse = dtAgentsWithWarehouse.NewRow();// dtWithoutMGM.NewRow(); drAgentWarehouse["MGMAgentNo"] = -1; drAgentWarehouse["Distributor"] = "Please select an agent..."; dtAgentsWithWarehouse.Rows.InsertAt(drAgentWarehouse, 0); ddlAgentsWithWarehouse.DataSource = dtAgentsWithWarehouse;// dtWithoutMGM; ddlAgentsWithWarehouse.DataBind(); //int iInternal = Convert.ToInt32(Session["Internal"]); //DataTable dtWithoutMGM = new DataTable(); //DataTable dtAgentsWithWarehouse = q.AgentsWithWarehouses(iInternal == 1 ? false : true); //ddlAgentsWithWarehouse.DataTextField = "Distributor"; //ddlAgentsWithWarehouse.DataValueField = "MGMAgentNo"; //dtWithoutMGM = dtAgentsWithWarehouse.AsEnumerable().Select(r => r).Where(d => Convert.ToInt32(d["MGMAgentNo"]) != 0).Select(v => v).CopyToDataTable(); //DataRow drAgentWarehouse = dtWithoutMGM.NewRow(); //drAgentWarehouse["MGMAgentNo"] = -1; //drAgentWarehouse["Distributor"] = "Please select an agent..."; //dtWithoutMGM.Rows.InsertAt(drAgentWarehouse, 0); //ddlAgentsWithWarehouse.DataSource = dtWithoutMGM; //ddlAgentsWithWarehouse.DataBind(); }