public void BindCombo(DropDownList ddl, LookupTypeEnum luType, string defaultText, string dataTextField, string dataValueField) { ddl.Items.Clear(); ddl.Items.Add(new ListItem(defaultText, string.Empty)); ddl.AppendDataBoundItems = true; List <LookupValue> ds = SimpleLookup.Lookup(luType).GetList(); ds.Sort(CompareByString); ddl.DataSource = ds; ddl.DataTextField = dataTextField; ddl.DataValueField = dataValueField; ddl.DataBind(); }
public static CascadingDropDownNameValue[] GetZone(string selectedRegion) { List <CascadingDropDownNameValue> lst; List <LookupValue> lus; Predicate <LookupValue> p = new Predicate <LookupValue>(l => l.RegionID == new Guid(selectedRegion)); lus = SimpleLookup.Lookup(LookupTypeEnum.Zones).GetList(p); lst = new List <CascadingDropDownNameValue>(); foreach (LookupValue l in lus) { lst.Add(new CascadingDropDownNameValue(l.Description, l.ID.ToString())); } return(lst.ToArray()); }
public void BindCombo(DropDownList ddl, LookupTypeEnum luType, Predicate <LookupValue> criteria, string defaultText) { ddl.Items.Clear(); ddl.Items.Add(new ListItem(defaultText, string.Empty)); ddl.AppendDataBoundItems = true; List <LookupValue> ds = SimpleLookup.Lookup(luType).GetList(criteria); ds.Sort(CompareByString); ddl.DataSource = ds; ddl.DataTextField = "Description"; ddl.DataValueField = "ID"; ddl.DataBind(); }
/// <summary> /// Populates existing information for update purpose, if it is text box then it fills the value /// if it is dropdown list then it chooses from one of the alternatives supplied by FillControls() method /// </summary> private void PopulateExistingData() { //if (theArrival.IsNew) return; GRNStatusNew GRNStatus; GRNStatusNew.TryParse(theArrival.GRNStatus.ToString(), out GRNStatus); if (GRNStatus == GRNStatusNew.New || GRNStatus == GRNStatusNew.NotCreated) { btnSave.Enabled = true; } else { btnSave.Enabled = false; btnSave.ToolTip = "Can't Update Arrival because this step is at " + GRNStatus.ToString() + " Stage"; } if (theArrival.WarehouseID != WarehouseBLL.CurrentWarehouse.WarehouseId) { Response.Redirect("ErrorPage.aspx"); } try { lblClient.Text = theArrival.ClientName; lblWarehouse.Text = WarehouseBLL.CurrentWarehouse.WarehouseName; isNonTruck.Checked = theArrival.IsNonTruck; cboCommodity.SelectedValue = theArrival.CommodityID.ToString(); //chkIsSourceDetermined.Checked = theArrival.IsLocationKnown; if (!theArrival.IsLocationKnown) { cboRegion.SelectedValue = Guid.Empty.ToString(); } else { LookupValue lv = SimpleLookup.Lookup(LookupTypeEnum.Woredas).GetDictionary()[theArrival.WoredaID]; cboRegion.SelectedValue = lv.RegionID.ToString(); cboRegion_SelectedIndexChanged(this, EventArgs.Empty); cboZone.SelectedValue = lv.ZoneID.ToString(); cboZone_SelectedIndexChanged(this, EventArgs.Empty); cboWoreda.SelectedValue = theArrival.WoredaID.ToString(); txtSpecificArea.Text = theArrival.SpecificArea; } cboProductionYear.SelectedValue = theArrival.ProductionYear.ToString(); txtProcessingCenter.Text = theArrival.ProcessingCenter; txtNumberOfBags.Text = theArrival.NumberofBags.ToString() == "0" ? "" : theArrival.NumberofBags.ToString(); txtWeight.Text = theArrival.VoucherWeight.ToString() == "0" ? "" : theArrival.VoucherWeight.ToString(); if ("1/1/1901" == theArrival.DateTimeReceived.ToShortDateString() || theArrival.DateTimeReceived.ToShortDateString() == "1/1/0001") { txtArrivalDate.Text = ""; txtTimeArrival.Text = ""; } else { txtArrivalDate.Text = theArrival.DateTimeReceived.ToShortDateString(); txtTimeArrival.Text = theArrival.DateTimeReceived.ToShortTimeString(); } txtRemark.Text = theArrival.Remark; if (!theArrival.IsNonTruck) { chkIsTruckInCompound.Checked = theArrival.IsTruckInCompound; txtDriverName.Text = theArrival.DriverName; txtLicenseNo.Text = theArrival.LicenseNumber; txtPlaceIssued.Text = theArrival.LicenseIssuedPlace; txtPlateNo.Text = theArrival.TruckPlateNumber; txtTrailerPlateNo.Text = theArrival.TrailerPlateNumber; txtNoPlomps.Text = theArrival.VoucherNumberOfPlomps.ToString() == "0" ? "" : theArrival.VoucherNumberOfPlomps.ToString(); txtTrailerNoPlomps.Text = theArrival.VoucherNumberOfPlompsTrailer.ToString() == "0" ? "" : theArrival.VoucherNumberOfPlompsTrailer.ToString(); } txtVoucherNo.Text = theArrival.VoucherNumber; hdnHasVoucher.Value = theArrival.HasVoucher.ToString(); //chkIsBiProduct.Checked = theArrival.IsBiProduct; if (Guid.Empty == theArrival.VoucherCommodityTypeID || string.IsNullOrEmpty(theArrival.VoucherCommodityTypeID.ToString())) { cboCommodityType.SelectedIndex = 0; cboCommodityType.Enabled = false; } else { cboCommodityType.SelectedValue = theArrival.VoucherCommodityTypeID.ToString(); } } catch (Exception ex) { //lblMessage.Text = "Failed to populate existing data!"; Messages.SetMessage("Existing data cannot be retrieved. Please try again.", WarehouseApplication.Messages.MessageType.Error); } }