Completed
Last Updated: 18 Oct 2016 10:19 by ADMIN
ADMIN
Dimitar
Created on: 12 Oct 2016 07:21
Category: GridView
Type: Bug Report
4
FIX. RadGridView - the last row is not updated when the grid is bound to IEditableObject
To reproduce:
DataTable table;
public RadForm1()
{
    InitializeComponent();
    table = GetTable();
    radGridView1.DataSource = table;

}

private void radButton1_Click(object sender, EventArgs e)
{
    var changes = table.GetChanges();

    if (changes == null)
    {
        Console.WriteLine("No Changes");
    }
    else
    {
        Console.WriteLine("Saved");

        foreach (DataRow item in changes.Rows) 
        {
            Console.WriteLine(item.RowState.ToString());
        }
    }

    table.AcceptChanges();
}
static DataTable GetTable()
{

    DataTable table = new DataTable();
    table.Columns.Add("Dosage", typeof(int));
    table.Columns.Add("Drug", typeof(string));
    table.Columns.Add("Name", typeof(string));
    table.Columns.Add("Date", typeof(DateTime));


    table.Rows.Add(25, "Indocin", "David", DateTime.Now);
    table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
    table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
    table.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
    table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);
    table.AcceptChanges();

    return table;
}

Workaround:
(this.radGridView1.CurrentRow.DataBoundItem as IEditableObject).EndEdit();
0 comments