Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: How to Populate a dropdownlist with dates


Message #1 by Sw RR <psrr79@y...> on Tue, 12 Nov 2002 17:49:27 -0800 (PST)
Hi all,

  I want to Populate the dropdownlist with the dates of only past month. This is very urgent. Any help in this regard

Thanks,

Psrr

 



---------------------------------
Do you Yahoo!?
U2 on LAUNCH - Exclusive medley & videos from Greatest Hits CD
Message #2 by "Ken Schaefer" <ken@a...> on Wed, 13 Nov 2002 13:47:03 +1100
Use a loop. Loop from the beginning of the month, until the end. Add each
date to the items collection of the dropdownlist.

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Sw RR" <psrr79@y...>
Subject: [aspx_beginners] How to Populate a dropdownlist with dates


:
: Hi all,
:
:   I want to Populate the dropdownlist with the dates of only past month.
This is very urgent. Any help in this regard

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Message #3 by psrr79@y... on Thu, 14 Nov 2002 00:32:20
Hi,
  I have populated the DropdownLists with Date and month. But the problem 
is I want the dates according to selected month. For instance if the month 
Dropdownlist is October which has value of 10 then dates Dropdownlist must 
have  dates from 1 to 31. If the month is November the Dates DropdownList 
must have dates  from only 1 to 30. But when I get the SelectedItem of the 
Month Dropdownlist I get an error as System.FormatException.Input string 
not in correct format.  Here is the code.

************************************
ddMonth1.Items.Clear();
ddMonth1.Items.Add("Month");
for(x=0;x<1;x++)
{
ddMonth1.Items.Add(new ListItem(intMonth.ToString(),x.ToString()));
ddMonth1.Items.Add(new ListItem(intMonth1.ToString(),x.ToString()));
}
ddDay1.Items.Clear();
ddDay1.Items.Add("Date");
////Error occurs in this line

int y=Convert.ToInt32(ddMonth.SelectedItem.Selected.ToString()); for
(x=1;x<=DateTime.DaysInMonth(DateTime.Now.Year,y);x++)
{ 
ddDay1.Items.Add(x.ToString());
}

******************************
Any help in this regard.

Thanks in Advance,
PSRR

  Return to Index