Nick,
> You can just set the DataSource to be a List<MyObject> and DataBind. You
> won't get any help with setting up the columns at design time if you do it
> that way - you'll have type in all the details. If you want design time
> help consider using an ObjectDataSource that points to a method that
> returns the list.
Yeah, that's how it's done with a List<string> so I thought that might work.
But, with my class defined like this:
public class ClientMenuItem
{
public int MealNum;
public float Substitutions;
public string Group;
public float Units;
public string Measure;
public string Description;
public float Calories;
public float Protein;
public float Carbohydrate;
public float Fat;
}
I tried the following:
List<ClientMenuItem> items = ClientUsers.GetMenuItems(menus[0].MenuID);
GridView1.DataSource = items;
GridView1.DataBind();
And I get the following error at runtime on the last line above:
"The data source for GridView with id 'GridView1' did not have any
properties or attributes from which to generate columns. Ensure that your
data source has content."
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com