deleting selected row in datagrid

N

NotYetaNurd

hi i have a datagrid binded to a datatable.
i want to delete the selected record in the datagrid i did something like this

CurrencyManager cm = (CurrencyManager) Grid.BindingContext[CommonDataset.Tables[0]];
DataRowView row = (DataRowView) cm.Current;
row.Delete();
cm.EndCurrentEdit();
DataRow[] dr=CommonDataset.Tables[0].Select(null,null,DataViewRowState.Deleted);
commonAdapter.Update(dr);

But somtimes the selected record is not deleted but some other record is deleted ......
 
M

Miha Markic [MVP C#]

How are you binding the dataset to grid?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com
hi i have a datagrid binded to a datatable.
i want to delete the selected record in the datagrid i did something like
this

CurrencyManager cm = (CurrencyManager)
Grid.BindingContext[CommonDataset.Tables[0]];
DataRowView row = (DataRowView) cm.Current;
row.Delete();
cm.EndCurrentEdit();
DataRow[]
dr=CommonDataset.Tables[0].Select(null,null,DataViewRowState.Deleted);
commonAdapter.Update(dr);

But somtimes the selected record is not deleted but some other record is
deleted ......
 
N

NotYetaNurd

actually ... i have a seperate form for adding new records ..
when i add new records and clear the dataset fill it once more then hit
delete this problem is happening (specifically happening for the every
second record i insert)
:-(


NotYetaNurd said:
Grid.DataSource=CommonDataset.Tables[0];

Miha Markic said:
How are you binding the dataset to grid?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com
hi i have a datagrid binded to a datatable.
i want to delete the selected record in the datagrid i did something like
this

CurrencyManager cm = (CurrencyManager)
Grid.BindingContext[CommonDataset.Tables[0]];
DataRowView row = (DataRowView) cm.Current;
row.Delete();
cm.EndCurrentEdit();
DataRow[]
dr=CommonDataset.Tables[0].Select(null,null,DataViewRowState.Deleted);
commonAdapter.Update(dr);

But somtimes the selected record is not deleted but some other record is
deleted ......
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top