Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 566451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:58:43+00:00 2026-05-13T12:58:43+00:00

I have an asp:DetailsView with several columns, e.g. Foo, Bar. I want to fill

  • 0

I have an asp:DetailsView with several columns, e.g. Foo, Bar.

I want to fill it with an anonymous type, i.e.:

gridView.DataSource = new { Foo = 1, Bar = "2" };
gridVeew.DataBind();

But getting next error:

Data source is an invalid type. It
must be either an IListSource,
IEnumerable, or IDataSource.

How can I do what I want?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:58:44+00:00Added an answer on May 13, 2026 at 12:58 pm

    The DataSource property expects a collection. The value you are assigning is not a collection.

    You will have to create a collection and put the anonymous typed instance into that collection. The following should probably work (though I’ve not tested it with DataSource):

    gridView.DataSource = new[] {new {Foo = 1, Bar = "2"}};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have asp:GridView displaying client requests using asp:SqlDataSource . I want to limit displayed
I have a control that look something like this: <asp:DetailsView ID=dvUsers runat=server DataSourceID=odsData DataKeyNames=Id>
I have the following detailsview in my asp.net web application. What it should show
I am creating a GridView/DetailsView page. I have a grid that displays a bunch
I am new to ASP.NET and have been trying to make the dropdownlist works
In ASP.net when we perform paging over Gridview or DetailsView than the Gridview fetch
I have a DetailsView like this: <asp:DetailsView ID=detailsView1 runat=server DataSourceID=edsdetailsView AutoGenerateRows=False CssClass=pretty-table> <Fields> <asp:TemplateField
My problem is like this: In ASP DetailsView component we have three different EventArgs
I have an asp.net webpage that contain a gridview with edit, select and delete
I have this markup: <asp:DetailsView ID=dvDatabase OnModeChanging=dvDatabase_ModeChanging> <HeaderTemplate> <asp:Button ID=btnView runat=server CausesValidation=False CommandName=Cancel Text=View

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.