fguihen Posted January 3, 2006 Posted January 3, 2006 i have a datagrid bound to a table. i am adding and deleting records using the datagrid. here is the code behind my delete button: private void button4_Click(object sender, System.EventArgs e) { int dfd = ds.Tables["visit_activities"].Rows.Count; foreach(DataRow r in ds.Tables["visit_activities"].Rows) { if(r.RowState == DataRowState.Deleted) { dfd = dfd - 1; } } if(dfd >= 0) { int i = this.dataGrid1.CurrentRowIndex; DataRow row = ds.Tables["visit_activities"].Rows[i]; row.Delete(); ds.Tables["visit_activities"].Rows.Remove(row); this.dataGrid1.Refresh(); } else {} } the problem is that this works most of the time, except sometimes when it doesnt remove the row as its still visible in the grid, yet it does not throw an error.i select the row i want to delete, click delete, all the code executes but nothing seems to happen. it happens when im down to 2 records left displayed in the dataGrid. can anyone tell me what might be happening Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.