protected void gvCustomerAddress_RowUpdating(object sender, GridViewUpdateEventArgs e) { this.ADDR_PKID = int.Parse(gvCustomerAddress.DataKeys[e.RowIndex].Values[0].ToString()); TextBox _txtCode = (TextBox)gvCustomerAddress.Rows[e.RowIndex].FindControl("txtCode"); TextBox _txtAddress = (TextBox)gvCustomerAddress.Rows[e.RowIndex].FindControl("txtAddress"); TextBox _txtTelephone = (TextBox)gvCustomerAddress.Rows[e.RowIndex].FindControl("txtTelephone"); TextBox _txtFax = (TextBox)gvCustomerAddress.Rows[e.RowIndex].FindControl("txtFax"); m_customer_address address = ListCustomerAddress.Find(x => x.ID == this.ADDR_PKID); if (address != null) { address.company_id = objCustomer.ID; address.code = _txtCode.Text; address.address = _txtAddress.Text; address.telephone = _txtTelephone.Text; address.fax = _txtFax.Text; } gvCustomerAddress.EditIndex = -1; gvCustomerAddress.DataSource = ListCustomerAddressShow; gvCustomerAddress.DataBind(); btnAdd.Enabled = true; }
protected void gvCustomerAddress_RowDeleting(object sender, GridViewDeleteEventArgs e) { this.ADDR_PKID = int.Parse(gvCustomerAddress.DataKeys[e.RowIndex].Values[0].ToString()); m_customer_address js = ListCustomerAddress.Find(x => x.ID == this.ADDR_PKID); if (js != null) { js.RowState = CommandNameEnum.Delete; gvCustomerAddress.DataSource = ListCustomerAddressShow; gvCustomerAddress.DataBind(); } btnAddCustomerAddress.Enabled = true; }
protected void btnAddCustomerAddress_Click(object sender, EventArgs e) { m_customer_address tmp = new m_customer_address(); tmp.ID = CustomUtils.GetRandomNumberID(); tmp.company_id = this.PKID; tmp.code = string.Empty; tmp.address = string.Empty; tmp.fax = string.Empty; tmp.telephone = string.Empty; tmp.RowState = CommandNameEnum.Add; ListCustomerAddress.Add(tmp); gvCustomerAddress.DataSource = ListCustomerAddressShow; gvCustomerAddress.PageIndex = 0; gvCustomerAddress.DataBind(); }