Solved

ASP.net: Creating an unbound 'list'?

Posted on 2003-11-12
5
542 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now