Ejemplo n.º 1
0
        private AddressItem GetUpdateItem()
        {
            var repeaterItem = rptAddressManager.Items[EditItemIndex];

            var ddlType               = ((DropDownList)repeaterItem.FindControl("ddlType"));
            var txtAttentionLine      = ((TextBox)repeaterItem.FindControl("txtAttentionLine"));
            var txtStreetAddressLine1 = ((TextBox)repeaterItem.FindControl("txtStreetAddressLine1"));
            var txtStreetAddressLine2 = ((TextBox)repeaterItem.FindControl("txtStreetAddressLine2"));
            var txtCity               = ((TextBox)repeaterItem.FindControl("txtCity"));
            var txtState              = ((TextBox)repeaterItem.FindControl("txtState"));
            var txtZip       = ((TextBox)repeaterItem.FindControl("txtZip"));
            var txtCountry   = ((TextBox)repeaterItem.FindControl("txtCountry"));
            var hidAddressID = (HiddenField)repeaterItem.FindControl("hidAddressID");

            var addrType = AddressTypes.First(x => x.Field == ddlType.SelectedValue).Field;

            var result = new AddressItem()
            {
                AddressID    = int.Parse(hidAddressID.Value),
                AddressType  = addrType,
                Attention    = txtAttentionLine.Text,
                AddressLine1 = txtStreetAddressLine1.Text,
                AddressLine2 = txtStreetAddressLine2.Text,
                City         = txtCity.Text,
                State        = txtState.Text,
                Zip          = txtZip.Text,
                Country      = txtCountry.Text
            };

            return(result);
        }
Ejemplo n.º 2
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            var footer                 = GetFooter();
            var ddlTypeF               = (DropDownList)footer.FindControl("ddlTypeF");
            var txtAttentionLineF      = (TextBox)footer.FindControl("txtAttentionLineF");
            var txtStreetAddressLine1F = (TextBox)footer.FindControl("txtStreetAddressLine1F");
            var txtStreetAddressLine2F = (TextBox)footer.FindControl("txtStreetAddressLine2F");
            var txtCityF               = (TextBox)footer.FindControl("txtCityF");
            var txtStateF              = (TextBox)footer.FindControl("txtStateF");
            var txtZipF                = (TextBox)footer.FindControl("txtZipF");
            var txtCountryF            = (TextBox)footer.FindControl("txtCountryF");

            if (!string.IsNullOrEmpty(txtStreetAddressLine1F.Text))
            {
                var type = AddressTypes.First(x => x.Field == ddlTypeF.SelectedValue).Field;

                AddressItem item = new AddressItem()
                {
                    AddressID    = 0,
                    AddressType  = type,
                    Attention    = txtAttentionLineF.Text,
                    AddressLine1 = txtStreetAddressLine1F.Text,
                    AddressLine2 = txtStreetAddressLine2F.Text,
                    City         = txtCityF.Text,
                    State        = txtStateF.Text,
                    Zip          = txtZipF.Text,
                    Country      = txtCountryF.Text
                };

                CreateAddress?.Invoke(this, new CreateAddressEventArgs()
                {
                    NewItem = item
                });
            }
        }