To reproduce: use the following code snippet and click the button twice.
private DataTable GetTable01()
{
DataTable table = new DataTable();
table.Columns.Add("Dosage", typeof(int));
table.Columns.Add("Drug", typeof(string));
table.Columns.Add("Patient", typeof(string));
table.Columns.Add("Date", typeof(DateTime));
// Here we add five DataRows.
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);
return table;
}
private void button1_Click_1(object sender, EventArgs e)
{
DataTable table01 = GetTable01();
radGridView1.Rows.Clear();
radGridView1.DataSource = table01;
}
WORKAROUND I:
this.radGridView1.DataError += radGridView1_DataError;
private void radGridView1_DataError(object sender, GridViewDataErrorEventArgs e)
{
if (e.Exception is ArgumentException && e.Exception.Message == "Cannot clear this list.")
{
this.radGridView1.BeginUpdate();
while (this.radGridView1.Rows.Count > 0)
{
this.radGridView1.Rows.RemoveAt(0);
}
this.radGridView1.EndUpdate();
}
}
WORKAROUND II:
while (this.radGridView1.Rows.Count > 0)
{
this.radGridView1.Rows.RemoveAt(this.radGridView1.Rows.Count - 1);
}