private void BindAddressesAndReservations()
 {
     ReservationsListView.DataSource = mgr.GetCustomerReservations(currentID);
     ReservationsListView.DataBind();
     AddressesListView.DataSource = mgr.GetCustomerAddresses(currentID);
     AddressesListView.DataBind();
     IsDataBound = true;
 }
        protected void AddressesListView_ItemDeleting(object sender, ListViewDeleteEventArgs e)
        {
            var contactId = (int)CustomerDetailsView.DataKey["ContactID"];
            var id        = (int)AddressesListView.DataKeys[0].Value;

            mgr.DeleteAddress(id, contactId);
            AddressesListView.DataSource = mgr.GetCustomerAddresses(currentID);
            AddressesListView.DataBind();
        }
        protected void AddressesListView_ItemInserting(object sender, ListViewInsertEventArgs e)
        {
            var contactId = (int)CustomerDetailsView.DataKey["ContactID"];
            var street1   = e.Values["Street1"] as string;
            var street2   = e.Values["Street2"] as string;
            var city      = e.Values["City"] as string;
            var state     = e.Values["StateProvince"] as string;
            var country   = e.Values["CountryRegion"] as string;
            var postal    = e.Values["PostalCode"] as string;
            var type      = e.Values["AddressType"] as string;

            mgr.InsertAddress(street1 as string, street2, city, state, country, postal, type, contactId);
            AddressesListView.EditIndex  = -1;
            AddressesListView.DataSource = mgr.GetCustomerAddresses(currentID);
            AddressesListView.DataBind();
        }
        protected void AddressesListView_ItemUpdating(object sender, ListViewUpdateEventArgs e)
        {
            //only send changed
            var contactId = (int)CustomerDetailsView.DataKey["ContactID"];
            var id        = (int)AddressesListView.DataKeys[0].Value;
            var street1   = e.NewValues["Street1"];
            //var street2 = e.NewValues["Street2"]!=null ? e.NewValues["Street2"].ToString() : null;
            var street2 = e.NewValues["Street2"] as string;
            var city    = e.NewValues["City"] as string;
            var state   = e.NewValues["StateProvince"] as string;
            var country = e.NewValues["CountryRegion"] as string;
            var postal  = e.NewValues["PostalCode"] as string;
            var type    = e.NewValues["AddressType"] as string;

            mgr.UpdateAddress(id, street1 as string, street2, city, state, country, postal, type, contactId);
            AddressesListView.EditIndex  = -1;
            AddressesListView.DataSource = mgr.GetCustomerAddresses(currentID);
            AddressesListView.DataBind();
        }
 protected void AddressesListView_ItemCanceling(object sender, ListViewCancelEventArgs e)
 {
     AddressesListView.EditIndex  = -1;
     AddressesListView.DataSource = mgr.GetCustomerAddresses(currentID);
     AddressesListView.DataBind();
 }
 protected void AddressesListView_ItemEditing(object sender, ListViewEditEventArgs e)
 {
     AddressesListView.EditIndex  = e.NewEditIndex;
     AddressesListView.DataSource = mgr.GetCustomerAddresses(currentID);
     AddressesListView.DataBind();
 }