473,385 Members | 1,461 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Calendar Control and Loops

I'm trying to find a way to loop through the Calendar Control and add
business days next to each day in the calendar after the SelectedDate.
Example: if a user selects May 2nd 2005, I want the calendar to display
|3-1|, |4-2|, |5-3|...etc.
I created a loop to display this. However, the loop is running first before
rendering it.
It looks like |3-1-2-3-4-5|, |4-1-2-3-4-5|, |5-1-2-3-4-5|...etc.

I currently have the loop set from 1 to 5, but once I get this working it
will be set from 1 to 90.

private void calWorkDays_DayRender(object sender,
System.Web.UI.WebControls.DayRenderEventArgs e)

{

for(int x = 1; x < 6; x++)

{

e.Cell.Controls.Add(new LiteralControl(" - " +
x.ToString()));
}

}

I have code that bypasses weekends and holidays. that all works fine. It's
this loop that's killing me. I have tried everything I can think of to get
this to work. I was thinking that a "foreach" might do the trick, but I
can't get the syntax right with it.

any help would greatly be appreciated,

thanks.
Nov 19 '05 #1
1 2326
Hi Greg:

Remember, DayRender fires once for each day in the calendar. You
wouldn't want to loop each time DayRender fires, what you need is a
counter.

int businessDaycounter = 1; // declare this at class scope

Each time DayRender fires you just need to write out the counter with
a LiteralControl as you have done, and then increment the counter (add
one). No looping needed.

--
Scott
http://www.OdeToCode.com/blogs/scott/
On Sat, 07 May 2005 01:46:54 GMT, "Greg Ellis" <no@where.com> wrote:
I'm trying to find a way to loop through the Calendar Control and add
business days next to each day in the calendar after the SelectedDate.
Example: if a user selects May 2nd 2005, I want the calendar to display
|3-1|, |4-2|, |5-3|...etc.
I created a loop to display this. However, the loop is running first before
rendering it.
It looks like |3-1-2-3-4-5|, |4-1-2-3-4-5|, |5-1-2-3-4-5|...etc.

I currently have the loop set from 1 to 5, but once I get this working it
will be set from 1 to 90.

private void calWorkDays_DayRender(object sender,
System.Web.UI.WebControls.DayRenderEventArgs e)

{

for(int x = 1; x < 6; x++)

{

e.Cell.Controls.Add(new LiteralControl(" - " +
x.ToString()));
}

}

I have code that bypasses weekends and holidays. that all works fine. It's
this loop that's killing me. I have tried everything I can think of to get
this to work. I was thinking that a "foreach" might do the trick, but I
can't get the syntax right with it.

any help would greatly be appreciated,

thanks.


Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tim Graichen | last post by:
Hello, I am making use of the Active X calendar control (mscal.Calendar.7) in several places in my main form, with the following code Below is an example of the code I'm using for the...
5
by: Miguel Dias Moura | last post by:
Hello, i am trying to create a .css file with several styles and apply them to the calendar control so i can change the look of: 1. Text Type and Format (Bold, Underline, etc) 2. Background...
1
by: bill yeager | last post by:
I would like to place the currently selected date (retrieved from the database) on a calendar control which is embedded inside a datagrid. However, I can't find the ID of the control to do so....
0
by: maxrawson | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many...
2
by: Caesar Augustus | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many...
3
by: Peter | last post by:
Is there anyway to make the System.Web.UI.WebControls.Calendar to display only Month Name and Year, like: January, 2006 February, 2006 ..... .... .... ....
3
by: =?Utf-8?B?UGFycm90?= | last post by:
I applied the following Ajax code in my web page which has a calendar control to keep my page from completely reloading everytime something was changed. <atlas:ScriptManager ID="ScriptManager1"...
7
by: John Kotuby | last post by:
Hi all, I am trying to use a calendar server control which I have ID="Calendar1" in the source code. What I am trying to do is emulate a JavaScript calendar that was being used in an older ASP...
3
by: thorpk | last post by:
I posted this problem earlier in the month and some one decided it was better to change the subject and ask a completely different question. I am therefore reposting. I am hoping some one can...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.