Ok, I have an Arraylist of custom objects, and I want to display these in a dataGrid. I keep getting an error when running the code I have developed.
---
A field or property with the name 'ID' was not found on the selected datasource.
---
My code:
if (myList.Count > 0) {
lblDebug.Text = myList.Count.ToString();
DataGrid1.DataSource = myList;
DataGrid1.DataBind ();
}
//The count is set to 3
<aspataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="ID" HeaderText="ID"></asp:BoundColumn>
</Columns>
</aspataGrid>
---
The custom object does have an ID property, and it is set through the constructor. I also want to display the other properties in the other fields, but I will settle to get just the one working for now.
What am I doing wrong?
---
A field or property with the name 'ID' was not found on the selected datasource.
---
My code:
if (myList.Count > 0) {
lblDebug.Text = myList.Count.ToString();
DataGrid1.DataSource = myList;
DataGrid1.DataBind ();
}
//The count is set to 3
<aspataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField="ID" HeaderText="ID"></asp:BoundColumn>
</Columns>
</aspataGrid>
---
The custom object does have an ID property, and it is set through the constructor. I also want to display the other properties in the other fields, but I will settle to get just the one working for now.
What am I doing wrong?