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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:27:13+00:00 2026-05-28T03:27:13+00:00

I’ve been asked to improve a ASP.Net C# page. It currently shows a years

  • 0

I’ve been asked to improve a ASP.Net C# page. It currently shows a years worth of daily prices for a product. The page looks similar to a wall planner, with each input control showing a price for that day.

The page will be used to change the price of this product for that year. Currently the ‘wall planner’ table control is being generated cell-by-cell in the code behind.

There is a lot of code used to implement this but essentially it does the following.

A table is built… dynamically

  1. New Table control defined
  2. 12 new TableRow controls defined (months)
  3. Each row has 31 TableCell controls added to it (Each with a unique id e.g. cell_yy_mm_dd)

Its filled with data

  1. 365 days of prices are retrieved from the database (Price and Date).
  2. Foreach used to loop over the dataset
  3. Date checked with the TableCells id. If there is a match, a new TextBox is added to the cell.

This is causing a huge strain on the server (specifically memory usage). It seems so over engineered there must be a better way of doing it!

What would be a better method to implement such functionality?

  • 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-28T03:27:14+00:00Added an answer on May 28, 2026 at 3:27 am

    This is how I would solve it. Using two repeaters, one for the months and one for the days.
    Using the current calendar I can than from code generate the months and the days using linq and left join with the values from the db on the Date.

    Code

    //The values from the DB
    var values = new List<DateValue>()
    { 
        new DateValue(){ Date = new DateTime(2012, 1, 12), Value = 5000 },  
        new DateValue(){ Date = new DateTime(2012, 11, 15), Value = 3000 }
    };
    
    var year = DateTime.Now.Year;
    var cal = System.Threading.Thread.CurrentThread.CurrentCulture.Calendar;
    
    //Generate the months and dates and left join with the values from the DB
    var q = from month in Enumerable.Range(1, cal.GetMonthsInYear(year))
            select new
            {
                Dates = from date in Enumerable.Range(1, 
                            cal.GetDaysInMonth(year, month))
                            .Select(day => new DateTime(year, month, day))
                        join tmp in values on date equals tmp.Date into g
                        from value in g.DefaultIfEmpty()
                        select new
                        {
                            Date = date,
                            Value = value == null ? new Nullable<Decimal>() : value.Value
                        }
            };
    
    //bind the query to the outer repeater
    repMonths.DataSource = q;
    repMonths.DataBind();
    

    DTO filled from DB

    public class DateValue
    {
         public DateTime Date { get; set; }
         public decimal Value { get; set; }
    }
    

    ASPX

    <table border="1">
          <asp:Repeater runat="server" ID="repMonths">
                <ItemTemplate>
                    <tr>
                        <asp:Repeater runat="server" ID="repDays" DataSource='<%# DataBinder.Eval(Container.DataItem, "Dates") %>'>
                            <ItemTemplate>
                                <td>
                                    <%# DataBinder.Eval(Container.DataItem, "Value")  %>
                                </td>
                            </ItemTemplate>
                        </asp:Repeater>
                    </tr>
                </ItemTemplate>
          </asp:Repeater>
    </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I'm making a simple page using Google Maps API 3. My first. One marker

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.