To reproduce: use the following code snippet:
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("IsActive", typeof(bool));
for (int i = 0; i < 20; i++)
{
if (i % 5 == 0)
{
dt.Rows.Add(i, "Item" + i, true);
}
{
dt.Rows.Add(i, "Item" + i, DBNull.Value);
}
}
this.radGridView1.DataSource = dt;
this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
this.radGridView1.EnableFiltering = true;
Try to filter by "Name" column via entering "4". As a result an InvalidCastException occurs.
Workaround: initialize default value for the cells belonging to GridViewCheckBoxColumn with false if it is DBNull:
foreach (GridViewRowInfo r in this.radGridView1.Rows)
{
if (r.Cells["IsActive"].Value == DBNull.Value)
{
r.Cells["IsActive"].Value = false;
}
}