Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP.net: Creating an unbound 'list'?

Posted on 2003-11-12
5
Medium Priority
?
553 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

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…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

618 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