Following Error in this line.
datagridview1.Rows.Clear()
but this line gives error:
Cannot clear this list.
Is your DataGridView bound to a DataSource, i think thats why its not allowing you to clear it since its bound to an underlying DataTable or List.
DataGridView
DataSource
DataTable
List
you could try setting the DataSource Property to null
datagridview1.DataSource = null; for clearing
datagridview1.DataSource = null;