protected void gvTaxTypes_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) { dsData = Session[Constants.SESSION_TAXTYPES] as DataSet; ASPxGridView gridView = sender as ASPxGridView; DataRow row = dsData.Tables[0].NewRow(); Random rd = new Random(); e.NewValues["TaxTypeId"] = rd.Next(); e.NewValues["StatusId"] = (int)Enums.HBMStatus.Active; e.NewValues["CompanyId"] = SessionHandler.CurrentCompanyId;; e.NewValues["CreatedUser"] = SessionHandler.LoggedUser.UsersId; IDictionaryEnumerator enumerator = e.NewValues.GetEnumerator(); enumerator.Reset(); while (enumerator.MoveNext()) { if (enumerator.Key.ToString() != "Count") { row[enumerator.Key.ToString()] = enumerator.Value == null ? DBNull.Value : enumerator.Value; } } gridView.CancelEdit(); e.Cancel = true; dsData.Tables[0].Rows.Add(row); taxType.TaxTypeName = e.NewValues["TaxTypeName"].ToString(); if (!taxType.IsDuplicateTypeName()) { if (taxType.Save(dsData)) { this.LoadTaxTypes(); } } else { throw new System.Exception(Messages.Duplicate_record); } }