You should really learn to use Goolgle and/or the MSDN documentation. The compiler already told you that there is no such property so you must have made a mistake. Why infact should there be a property ColumnCount on the gridview itself? The gridview already has a collection of its columns exposed as the property named, appropriately I must say,
Columns
. Knowing a bit about object orientation, who in your opinion should know about the number of columns present in that collection?
If your answer was the collection itself, then you are one hundred percent correct! So now you either go to the MSDN documentation and hunt down all the properties present in the collection exposed by the gridview's property named
Columns
, or you do some fancy guesswork as properties denoting the number of elements in some collection are usually called
Count
you go and try this instead:
gridViewNameWhatEverThatMayBe.Columns.Count
As I'm seeing that you are trying to assign to Count I must say you're
out of luck as this property is readonly[
^]. You'll have to find some other way to add columns and rows to your gridview.
Regards,
Manfred