Ejemplo n.º 1
0
        protected void FindByPartialStreetAddress_Click(object sender, EventArgs e)
        {
            AddressDetailList.DataSource = null;
            AddressDetailList.DataBind();

            if (string.IsNullOrEmpty(AddressNumber.Text) || string.IsNullOrEmpty(AddressStreet.Text))
            {
                errormsgs.Add("Please provide Number and Street to search.");
                LoadMessageDisplay(errormsgs, "alert alert-danger");
            }
            else
            {
                try
                {
                    AddressesController sysmgr = new AddressesController();
                    List <Addresses>    info   = sysmgr.Addresses_FindByPartialStreetAddress(AddressNumber.Text, AddressStreet.Text);


                    if (info.Count == 0)
                    {
                        errormsgs.Add("No data found for the supplied number and street.");
                        LoadMessageDisplay(errormsgs, "alert alert-danger");
                        AddressDetailList.DataSource = null;
                        AddressDetailList.DataBind();
                    }
                    else
                    {
                        info.Sort((x, y) => x.FullAddress.CompareTo(y.FullAddress));
                        //Second Dropdown list drill down
                        AddressDetailList.DataSource     = info;
                        AddressDetailList.DataTextField  = nameof(Addresses.FullAddress);
                        AddressDetailList.DataValueField = nameof(Addresses.AddressID);
                        AddressDetailList.DataBind();
                        AddressDetailList.Items.Insert(0, "Select an Address...");
                    }
                }
                catch (Exception ex)
                {
                    errormsgs.Add(GetInnerException(ex).ToString());
                    LoadMessageDisplay(errormsgs, "alert alert-danger");
                }
            }
        }