Hi
I have a calendar that I generate. Currently it makes the entire month and fills each cell with a number(representing the date).
Now I want to grab values from a database and fill in the cells. How could I do this efficiently?
Like right now I can only think of grabbing the data from the database. Once that is down going through that data and essentially have like 30 if statements to determine what cell it should go into.
So that just seems like a very bad way and I am thinking of better ways. So I am wondering anyone else has any ideas.
I am using asp.net mvc I generate the body of the calendar(what is just a table) through my controller and pass it as just a string of html cells and rows.
So basically I generate in the controller all 6 rows of 7 cells(42 cells with 2 cells for previous month and remaining cells for the next month - basically looks like the windows 7 calendar) with the TagBuilder and return that as one big string.
So while building the cells that's what I would have to put the if statements to do the checking.
I am using linq to sql by the way so not sure if that will help or not.
Edit
Another way what I was thinking but not sure how to do it. Would be some how getting all the dates in range. Then take those results and do some grouping on those results. Not sure how to that kind of grouping though. It probably would not be to bad if I do the grouping on the first results and not do a request for each date and then group that. Otherwise I am looking at like 42 requests to the database to group everything.