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)
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)
Response by poster: Thanks hincandenza, I haven't tried that yet! I'll give your idea a shot this afternoon and see if I can make it work :)
posted by geeky at 4:52 AM on August 19, 2005
posted by geeky at 4:52 AM on August 19, 2005
.... aaaaaaaaaaaaaaaaaaaand?
posted by hincandenza at 4:14 PM on August 21, 2005
posted by hincandenza at 4:14 PM on August 21, 2005
Response by poster: Still working on it... took a break on writing my code to explore some other pre-packaged options. I'll keep you posted :)
posted by geeky at 11:38 AM on August 22, 2005
posted by geeky at 11:38 AM on August 22, 2005
Response by poster: OK, I got into it this afternoon and... it worked! Thanks so much for your help, don't know why I didn't think to try it this way before :)
posted by geeky at 1:01 PM on August 22, 2005
posted by geeky at 1:01 PM on August 22, 2005
No probs, geeky- was just curious if it worked! I had the same issue myself on something back in the day, trying to make a datagrid or datalist behave a certain way, then realized I could just do a table, and have all that flexibility directly!
posted by hincandenza at 2:05 PM on August 22, 2005
posted by hincandenza at 2:05 PM on August 22, 2005
This thread is closed to new comments.
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