Data record delete from XtraGrid (devexpress) but not delete from database table

Posts   
 
    
nopchan
User
Posts: 56
Joined: 30-Apr-2005
# Posted on: 13-Sep-2005 04:14:09   

I'm using XtraGrid (devexpress.com) with data adapter model ,when I select row then click [-] delete navigator (DevExpress.XtraEditors.NavigatorButton) data record delete from xtragrid but can not delete from entity collection when adapter.SaveEntityCollection

adapter.StartTransaction(IsolationLevel.ReadCommitted, "Edit Data"); GrBankAccCollection = new EntityCollection(new BankaccEntityFactory()); RelationPredicateBucket bucket = new RelationPredicateBucket(); bucket.PredicateExpression.Add(PredicateFactory.CompareValue(BankaccFieldIndex.CompanyId, ComparisonOperator.Equal, SetCompanyID.ToString())); GrBankAccCollection.AllowRemove = true; adapter.FetchEntityCollection(GrBankAccCollection,bucket); BankAccGrid.DataSource = GrBankAccCollection;

I select row then click delete navigator then data record delete from grid complete ,data is not display in grid when clieck delete but

adapter.SaveEntityCollection(GrBankAccCollection); adapter.Commit();

Data record is not delete from table of sql database. (sql2000)

when I move xxxx.AllowRemove = true; to after FetchEntityCollection Data record is not delete from database table too.

adapter.FetchEntityCollection(GrBankAccCollection,bucket); GrBankAccCollection.AllowRemove = true; BankAccGrid.DataSource = GrBankAccCollection;

nopchan
User
Posts: 56
Joined: 30-Apr-2005
# Posted on: 14-Sep-2005 05:23:49   

I can work now.

with event add for XtraGrid

example

this.BankGrid.EmbeddedNavigator.ButtonClick += new NavigatorButtonClickEventHandler(buttonClick);

private void buttonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e) { string SelectBankId ; if(e.Button.ButtonType == DevExpress.XtraEditors.NavigatorButtonType.Remove) { SelectBankId = gridView1.GetFocusedRowCellValue(gridView1.Columns.ColumnByFieldName("BankId")).ToString(); BankEntity Bankacc = new BankEntity(SelectBankId); adapter.DeleteEntity(Bankacc);

}

}