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 8944221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:58:35+00:00 2026-06-15T11:58:35+00:00

I am creating a custom control extending WebControl. This web control allows the consumer

  • 0

I am creating a custom control extending WebControl. This web control allows the consumer to define a collection of columns in markup, something like this:

<Custom:CustomGrid>
<Columns>
    <Custom:DataColumn HeaderText="FirstName" />
    <Custom:DataColumn HeaderText="LastName" />
</Columns>

and put an IEnumerable in a DataSource property and this is rendered out to a table.
This control also allows paging. The IEnumerable in DataSource is the full list, and I display a page of the list at a time. I am already saving the current page, number of rows per page, etc. to viewstate. Should I also put the full list in viewstate? Maybe session?
This list can become a bit hefty. Maybe save in session with a random key, which is saved in viewstate?
What is the best practice here?

Edit: I don’t think it’s right to impose that all types in the IEnumerable be serializable. Is that fair? So do I need to copy the data source to some other data structure for serialization?

Edit 2: Even if I do use a base control instead of implementing RenderChildControls I will need to implement CreateChildControls, but I will still need to persist the data somewhere, or did I miss the point of the base class?

  • 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-15T11:58:36+00:00Added an answer on June 15, 2026 at 11:58 am

    Indeed, not all IEnumerable instances will be serializable.

    If the query is cheap to run I wouldn’t persist the whole data set but just run the query again for a different page or a change in the sort order.

    If you put the data in viewstate you’ll end up with huge pages. Session state might be acceptable if you don’t have many users, but large data sets with lots of users won’t scale well. What if I bind a million rows to your control? Or what if your control was used in a repeater and shown 100 times on a page?

    Are you sure you need to persist the data? This isn’t premature optimisation is it?

    Remember that your control is a UI component. The viewstate should hold enough information to maintain the UI state as it is. A change in state (e.g.: switching to a different page of results) is something for which your control should pass responsibility to the data source.

    Take a look at good old GridView. It displays what you give it and remembers that. If you’re using paging then it raises an event to say “the user has changed page; give me page x of data”. For me, that’s the best practice for a UI control.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a custom control with markup like this: <Custom:CustomGrid> <Columns> <Custom:DataColumn HeaderText=FirstName
I dream of creating a control which works something like this: <asp:SqlDataSource id=dsFoo runat=server
I am creating a simple custom control extending from toggle button that allows the
I feel like I've missed something obvious, but when creating a custom control in
I'm creating a custom control called ImageFader. The style template looks like this: <ControlTemplate
I am creating a custom control. I want the template for this control to
I'm creating a custom control for my WPF application, and I'd like to know
I am creating a custom compounding control extending LinearLayout. Inside of its constructor, program
I am creating a custom server control to generate button elements with specific markup
So I'm creating a custom user control in .NET 2.0 and this user control

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.