This is a migrated thread and some comments may be shown as answers.

Removing Rows in SelectedRows

0 Answers 81 Views
GridView
This is a migrated thread and some comments may be shown as answers.
HamiD Mayeli
Top achievements
Rank 1
HamiD Mayeli asked on 22 Oct 2009, 11:04 AM
Hello,

I`m using Q3 2008 WinForms, And i use RadGridView and wanna Remove some rows when user click on a bottum on form. I used this code to remove rows one by one.

DialogResult mr = new DialogResult();  
mr = MessageBox.Show("Are U Sure?");  
if (mr == DialogResult.OK)  
            {  
                Telerik.WinControls.UI.GridViewDataRowInfo Row;  
                int RCount = GridHdr.SelectedRows.Count();  
                for (int I = RCount - 1; I > -1; I--)  
                {  
                    Row = (Telerik.WinControls.UI.GridViewDataRowInfo)GridHdr.SelectedRows[I];  
                    Row.Delete();  
                    BindingSourceHdr.EndEdit();  
                    AdapterHdr.Update(dBDataSet);  
                }  
            } 

before this code i`m using foreach statement but in two statement i have problem whit Removing
foreach(GridViewDataRowInfo Row in GridHdr.SelectedRows)  
{  
  Row.Delete();
  BindingSourceHdr.EndEdit();  
  AdapterHdr.Update(dBDataSet);  
when one row was deleted SelectedRows Collection was change and exception occord in runtime.

Regards
Hamid

No answers yet. Maybe you can help?

Tags
GridView
Asked by
HamiD Mayeli
Top achievements
Rank 1
Share this question
or