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
- New Table control defined
- 12 new TableRow controls defined (months)
- Each row has 31 TableCell controls added to it (Each with a unique id e.g. cell_yy_mm_dd)
Its filled with data
- 365 days of prices are retrieved from the database (Price and Date).
- Foreach used to loop over the dataset
- 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?
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
DTO filled from DB
ASPX