?
Solved

ASP.net: Creating an unbound 'list'?

Posted on 2003-11-12
5
Medium Priority
?
555 Views
Last Modified: 2011-04-14
I need to output a list of Days (in a month) to the screen, i.e. first time the page loads, I want to output all the days in November; 1-30 vertically, almost in a diary style. For each of these days that are output to the screen, I will perform a check to the database to see if there are any activities associated with this date, and output any found activities within this 'day cell'.

In Classic ASP I would have a simple FOR...NEXT loop to output each of the days in the month, and within that block, perform the database checks, however, I'm not sure how to do this kind of thing best in .NET as so far, all of my lists have been databound repeater controls, or datagrid controls. I did have a brief look at the methods of the DataList control but it looked like this needed a datasource bound to it also?

Any suggestions on how I should go about doing this task would be much appreciated.

Thanks
0
Comment
Question by:fatboy6
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
thomasdodds earned 100 total points
ID: 9734428
you could use a server side table ... doing your for..next loop adding a new rown and cell like you would have done with classic asp

or

you can use one of the server controls and add Items to them:

ei:

DataGrid has Items collection to which you can add (Datagrid.Items.Add()) a DataGridItem object
0
 
LVL 2

Assisted Solution

by:yleviel
yleviel earned 100 total points
ID: 9735246
Are you implying that you would actually call the DB 30 times?  If so I hope you realize why that is a really BAD idea if you want any performance on your site.  If the site is relatively small, the penalty will be unnoticed, but its better to just do it right the first time around.  use a SELECT and set the WHERE clause to the two date ranges you need and ORDER it by date so that its all nice and neat:

SELECT someField WHERE someDate BETWEEN '11/1/03' AND '12/1/03' ORDER BY someDate

This of course could be written alot better,  but I think you'll get the point. Once you have the recordset of info then do a programmatic compare to see where to place the info in the calandar.  If the data rarely changes, consider cacheing the info too to minimize DB hits.

Hope it helps in your development,
Yair
0
 
LVL 6

Expert Comment

by:thomasdodds
ID: 9739064
good point ... I wouldn't advise doing a round trip to the DB with every row either ... my comment was mainly on the web control portion of the question ... again, you raise a very valid point!

thx
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 10267884
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: thomasdodds {http:#9734428} & yleviel {http:#9735246}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question