Is there a way to display a calendar of less than a month in ASP.NET?
-
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)
-
Answer:
You might have luck with the http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconIntroductionToTableWebControl.asp object. You didn't say if this was interactive (editable) or not, but even if interactive you could still make the cells or individual words clickable to edit in another pane/window/etc. 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. [pseudo code] declare r and c as integers create table object set table properties like gridlines, etc ' create 4 rows, with rows 1 and 3 being the headers For r = 1 to 4 add tablerow to table object for c = 1 to 7 add cell to row use standard .net datetime methods and math, figure out date/day from r & c values if r mod 2 then call some DB and get the list of reservations for this date else print day and date with cell shading, etc for the header rows end if next Next [/pseudo code]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).
geeky at Ask.Metafilter.Com Visit the source
Other answers
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 :)
geeky
.... aaaaaaaaaaaaaaaaaaaand?
hincandenza
Still working on it... took a break on writing my code to explore some other pre-packaged options. I'll keep you posted :)
geeky
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 :)
geeky
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!
hincandenza
Related Q & A:
- Is there a way of putting the Python Shell output in a tkinter window?Best solution by Stack Overflow
- Is there a way of creating a interactive word document?Best solution by pcworld.com
- Is there a way to utilize a directv receiver for local HD reception without a subscription?Best solution by Yahoo! Answers
- How do you get rid of bacne in less than a month?Best solution by wikihow.com
- Is there a way to export the calendar in my group?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.