This is a migrated thread and some comments may be shown as answers.

RadComboBox Cannot get DateTime.Now

1 Answer 10 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
ratan mishra
Top achievements
Rank 1
ratan mishra asked on 15 Dec 2009, 04:35 PM
Hi All,

Here i am using RadComboBox of years where i am using for loop to add years into the RadComboBox but i am unable to add i am getting error which is hilighted in Bold how can i convert DateTime.Now into sting and add it to the RadComboBox 

Here is the code

for (int i = DateTime.Now.Year; i >= 1920; i--){ddlYear.Items.Add(i.ToString());}

Can any one help me.

Thanks in Advance.

1 Answer, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 15 Dec 2009, 08:36 PM
This should take care of it:
             
RadComboBoxItem myItem; 
for (int i = DateTime.Now.Year; i >= 1920; i--) 
    myItem = new RadComboBoxItem(i.ToString()); 
    RadComboBox1.Items.Add(myItem); 

Tags
ComboBox
Asked by
ratan mishra
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Share this question
or