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;
}