Solved

ASP.net: Creating an unbound 'list'?

Posted on 2003-11-12
5
548 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 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

Turn Insights Into Action

You’ve already invested in ITSM tools, chat applications, automation utilities, and more. Fortify these solutions with intelligent communications so you can drive business processes forward.

With xMatters, you'll never miss a beat.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

696 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