I've got some homework to do, but I cannot go through this issue. I want my .aspx page to display my database records, one below another. In order to do this I use a GridView, while the data is stored in an ArrayList. This ArrayList is composed of User objects, where each user has a first name, last name etc. (all the common stuff).
My code looks like this:

GridView myDataGrid = new GridView();
        myDataGrid.DataSource = myArrayList;

When I run thi thing in the browser, it keeps telling me: "The data source for GridView with id '' did not have any properties or attributes from which to generate columns. Ensure that your data source has content." - which is funny, since I know for sure that my arraylist contains exactly 4 User objects...

Could somebody help me please? What is the error in my code?
Tanks in advance.

8 Years
Discussion Span
Last Post by serkan sendur

the error is fair, you have to tell which property to be bound to columns in gridview. your user object has to have public properties so that the gridview can populate the column values. the properties must be in the form of property not a field. so not something like public string abc but like public string abc{ set ; get;}
try what i told, if there is still a problem let me know.

Thank you for the nice explanation
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.