Is there a way to display a calendar of less than a month in ASP.NET?
August 18, 2005 1:14 PM
Subscribe
Is there a way to display a calendar of less than a month in ASP.NET?
I'm working on creating a reservations system at work with ASP.NET and a database. Ideally, I would like to display a week or two at a time, with the dates listed across the top and each day having several reservations listed under it.
I have a way to display the reservations in the ASP.NET Calendar, but I would like to only display a week or two at a time, not the whole month. I feel like I've tried everything I can think of, including using a DataList and a Repeater, but nothing seems to be working. It seems like it should be fairly easy to display a weeks worth of dates with their corresponding reservations in a calendar format, but it's proving to be a lot more difficult that I had imagined.
I do have an alternate approach to this problem in mind, but I wanted to exhaust all possibilities for this approach first. Am I missing something here, or is this really as impossible as it seems?
(I am aware that there are 3rd party calendar components available for .NET that do weekly calendar views, but we do
not have the budget to buy any of them)
posted by geeky to computers & internet (6 comments total)
Since all you're really trying to do is make a pretty table with header rows, and reservation information underneath, then the table object would let you rip out a quick 7x4 grid with custom formatting and sizing based on the number of the row and column, as well as databinding. A table object would let you do a simple loop right in the .aspx, declaring a table object, using a loop of 'r' from 1 to 4 adding rows (essentially, row 1 is Dates and Day names, as is row 3, while row 2 and 4 are the actual reservations), and nested in that a loop of 'c' from 1 to 7 adding cells.
The nice thing is, you can have the row/cell formatting done however you want it, since for each cell you'd just do some fairly simple existing .net DateTime type calculations to determine what the day and date are for each cell based on the year, month, and starting date of your 1 or 2 week view.
Once you have that, depending on whether it's an odd or even numbered row do either a nicely formatted "header" cell saying Sunday the 14th, or do a db query to get the reservations for this particular date (might be better to get the month's reservations as a dataset first, and then use that dataset on each cell computation for speed).
posted by hincandenza at 12:39 AM on August 19, 2005