c# - Fill DetailsView.DataSource with anonymous type -
I have a asp: DetailsView
with multiple columns, e.g. Foo, bar
I have to fill it with an anonymous type, that is:
gridView.DataSource = new {Foo = 1, bar = "2"}; GridVeew.DataBind ();
but the following error is taking place:
The data source is an invalid type. It should either be an ILISISOS, INIMERABLE, or IDATOS.
What can I do if I want to?
Datasource is expected to store assets that the value you are assigning is not a collection.
You have to create an archive and give an anonymous typed example in that collection. The following should probably work (though I did not test it with datasource):
gridView.DataSource = new [] {new {Foo = 1, bar = "2"}} ;
Comments
Post a Comment