Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not determine metatable error binding list to asp.net datagridview

I am working with the following block of code ...

List<ThemeObject> themeList = (from theme in database.Themes
                            join image in database.DBImages on theme.imageID equals image.imageID
                            into resultSet
                            from item in resultSet
                            select new ThemeObject { Name = theme.Name, ImageID = item.imageID}).ToList();
dgvGridView.DataSource = themeList;
dgvGridView.DataBind();

The list object populates fine. The datagrid is setup with 2 columns.

  • A textbox column for the "Name" which is bound to "Name"
  • An image column which is bound to the "ImageID" field

When I execute the code I receive the following error on the DataBind()

Could not determine a MetaTable. A MetaTable could not be determined for the data source '' and one could not be inferred from the request URL. Make sure that the table is mapped to the dats source, or that the data source is configured with a valid context type and table name, or that the request is part of a registered DynamicDataRoute.

I'm not using any dynamicdataroutes as far as I can tell. Has anyone experienced this error before?


1 Answers

Assuming you are developing a Dynamic Data Entities web application (that's what the error you provided hints about), try this in your Page_Init:

dgvGridView.EnableDynamicData(typeof(ThemeObject));
like image 129
Maxim Gueivandov Avatar answered Sep 20 '25 16:09

Maxim Gueivandov