protected void gridviewBankBranch_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { ASPxGridView gridview = (ASPxGridView)sender; try { string code = (string)e.NewValues["Code"]; string name = (string)e.NewValues["Name"]; string description = (string)e.NewValues["Description"]; string address = (string)e.NewValues["Address"]; string phonefax = (string)e.NewValues["PhoneFax"]; if (name == null) { name = String.Empty; } if (description == null) { description = String.Empty; } if (address == null) { address = String.Empty; } if (phonefax == null) { phonefax = String.Empty; } CriteriaOperator criteria = new BinaryOperator("BankId", gridview.GetMasterRowKeyValue()); Bank bank = session.FindObject <Bank>(criteria); BankBranch bankBranch = new BankBranch(session); bankBranch.Code = code; bankBranch.Name = name; bankBranch.Description = description; bankBranch.Address = address; bankBranch.PhoneFax = phonefax; bankBranch.BankId = bank; bankBranch.Save(); } catch (Exception) { throw; } finally { e.Cancel = true; gridview.CancelEdit(); } }
protected void gridviewBankBranch_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) { ASPxGridView gridview = (ASPxGridView)sender; try { string code = (string)e.NewValues["Code"]; string name = (string)e.NewValues["Name"]; string description = (string)e.NewValues["Description"]; string address = (string)e.NewValues["Address"]; string phonefax = (string)e.NewValues["PhoneFax"]; if (name == null) { name = String.Empty; } if (description == null) { description = String.Empty; } if (address == null) { address = String.Empty; } if (phonefax == null) { phonefax = String.Empty; } Guid bankBranchId = (Guid)e.Keys["BankBranchId"]; BankBranch bankBranch = session.GetObjectByKey <BankBranch>(bankBranchId); bankBranch.Code = code; bankBranch.Name = name; bankBranch.Description = description; bankBranch.Address = address; bankBranch.PhoneFax = phonefax; bankBranch.Save(); } catch (Exception) { throw; } finally { e.Cancel = true; gridview.CancelEdit(); } }