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

  • Home
  • SEARCH
  • 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 8955239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:30:21+00:00 2026-06-15T14:30:21+00:00

I have a custom control with a data source of type IEnumerable (non-generic). Now

  • 0

I have a custom control with a data source of type IEnumerable (non-generic). Now I want to implement paging on the data source, and so I need something like Skip and Take, which List-of-T has. Right now I am using the following:

List<object> pagingList = DataSource.Cast<object>().ToList()

This can be inefficient, I’m guessing, so I’m looking for a better way to do this. Enumerating the collection, skipping elements and such with two counters might be more efficient, but it’s so ugly I just don’t want to do it. But maybe it’s the best choice?

  • 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-06-15T14:30:22+00:00Added an answer on June 15, 2026 at 2:30 pm

    Why are you calling ToList()? You can use Skip and Take without that:

    IEnumerable<object> paged = DataSource.Cast<object>()
                                          .Skip(page * pageSize)
                                          .Take(pageSize);
    

    That will save converting the whole data source to a list – but it does mean you can’t skip efficiently when the source isn’t an IList<T>.

    Two important questions though:

    • You mention that you guess your original code is inefficient… have you measured? How big is this data, and what’s its form in memory? What else are you doing with it? Is this really a bottleneck? Collect facts rather than guessing.
    • It would be easier to use your data in various ways if you had a generic data source… is that something you could achieve?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom control (C#, visual studio). I want to show a tooltip
I have a set of data templates I am using for my custom control.
I'm trying to implement drag and drop capability into a custom data grid control.
I have a custom GridView Control where I grab data from the database to
I need to create a custom control containing a combobox whose popup will have
I have custom server control contains templatefield when an out button clicked the field
I have a custom control which displays results of some operations. It is hidden
I have a custom control with a public collection marked as DesignerSerializationVisibility.Content . When
I have a Custom Control that has multiple textbox fields and a checkbox contained
I have a custom control that inherits from UserControl , and I can't get

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.