Completed
Last Updated: 07 Mar 2016 13:30 by ADMIN
ADMIN
Dimitar
Created on: 15 Feb 2016 16:10
Category: GridView
Type: Bug Report
1
FIX. RadGridView - NullReferenceException when the data source is reset and the rows are formated upon condition in the RowFormatting event.
To reproduce:
- Sort the grid and then reset the data source.
- Format the rows like this:
void radGridView1_RowFormatting(object sender, Telerik.WinControls.UI.RowFormattingEventArgs e)
{
    string exception_status = "";
    string completed_user = "";

    if (!DBNull.Value.Equals(e.RowElement.RowInfo.Cells["Name"].Value))
    {
        exception_status = e.RowElement.RowInfo.Cells["Name"].Value.ToString();
    }

    if (!DBNull.Value.Equals(e.RowElement.RowInfo.Cells["Drug"].Value))
    {
        completed_user = e.RowElement.RowInfo.Cells["Drug"].Value.ToString().Trim();
    }

    if (exception_status == "Sam" && completed_user == "Enebrel")
    {
        e.RowElement.ForeColor = Color.Red;
    }
    else
    {
        e.RowElement.ForeColor = Color.Black;
    }
}
Workaround:
if (e.RowElement.RowInfo.Cells.Count ==0)
{
    return;
}
0 comments