Solved

ASP.net: Creating an unbound 'list'?

Posted on 2003-11-12
5
546 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
5 Comments
 
LVL 6

Accepted Solution

by:
thomasdodds earned 25 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 25 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Where is this file? 3 32
Need syntax help building hyperlink 2 39
How to repeat the data 4 30
.NET - find out if application is running on Windows 2012 server 3 30
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

685 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