Completed
Last Updated: 19 Feb 2016 15:46 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 21 Jan 2016 14:13
Category: GridView
Type: Bug Report
0
FIX. RadGridView - CurrentRowChanged event is not fired after repopulating the grid with the same DataSource
Note: as a result ArgumentException is thrown when accessing a cell value.

To reproduce:

private DataTable dt;
private GridViewRowInfo selectedRow;

public Form1()
{
    InitializeComponent();

    PopulateGrid();
    PopulateGrid();
} 

private void PopulateGrid()
{
    dt = new DataTable();
    dt.Columns.Add("Version No", typeof(Int32));

    DataRow dr = dt.NewRow();
    dr["Version No"] = 2385;
    dt.Rows.Add(dr);

    this.radGridView1.DataSource = dt;

    MessageBox.Show(selectedRow.Cells[0].ColumnInfo.Name);
    MessageBox.Show(selectedRow.Cells[0].Value.ToString()); //This will error on the second time through
}

private void radGridView1_CurrentRowChanged(object sender, CurrentRowChangedEventArgs e)
{
    //This event is not firing on the second population of the grid in the new Telerik version.
    //In the old version, it did

    if (!this.radGridView1.CurrentRow.IsSystem && !this.radGridView1.CurrentRow.HasChildRows() && this.radGridView1.CurrentRow.Cells.Count > 0)
        selectedRow = this.radGridView1.CurrentRow;
}

Workaround: use the RadGridView.CurrentRow property directly when accessing the cell value.
0 comments