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

DataTable.RejectChanges fails with RowNotInTableException

1 Answer 64 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Anton
Top achievements
Rank 1
Anton asked on 03 Jun 2013, 01:04 PM
Steps to reproduce:
1. Add to project telerik controls v2011.3.1220.40
2. Create DataView and bind to grid:
           
DataTable dt = new DataTable("test");
for (int i = 0; i < 10; i++)
{
    dt.Columns.Add("column" + i);
}
for (int i = 0; i < 10; i++)
{
    var row = dt.NewRow();
    for (int j = 0; j < 10; j++)
    {
        row[j] = j + i;
    }
    dt.Rows.Add(row);
}
dt.AcceptChanges();
 
Items = dt.AsDataView();

<Grid>   
     <
Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="253*" />
    </Grid.RowDefinitions>
    <Button Command="{Binding UndoAllChanges}" Content="Undo all changes" Margin="10" HorizontalAlignment="Left" Padding="5,2" />
    <telerik:RadGridView ItemsSource="{Binding Items}" CanUserInsertRows="True" ShowInsertRow="True" Grid.Row="1" />
</Grid>


3. Add Undo function:
private ICommand _undoAllChanges;
public ICommand UndoAllChanges
{
    get
    {
        if (_undoAllChanges == null)
        {
            _undoAllChanges = new DelegateCommand(obj =>
            {
                Items.Table.RejectChanges();
                OnPropertyChanged("Items");
            });
        }
        return _undoAllChanges;
    }
}
4. To reproduce bug need to run application, sort by column1, add new item, set cell [ newRow, column1 ] to "1", click enter and then undo button.

P.S. I can't upload zip file because it's not allowed.

1 Answer, 1 is accepted

Sort by
0
Yordanka
Telerik team
answered on 04 Jun 2013, 10:55 AM
Hi Anton,

Could you test your solution with Q1 2013 SP1 official version - 2013.1.0403? I've tried your code and I couldn't reproduce the reported exception.
 
Regards,
Yordanka
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Anton
Top achievements
Rank 1
Answers by
Yordanka
Telerik team
Share this question
or