• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 371
  • Last Modified:

how to loop through a list to datetime pickers ?

hello i am having 12 datetime pickers in a form (AppDate1,AppDate2...)
. I am trying to get their values like this

for(i=0;i<n;i++)
{
          RadDateTimePicker Date = new RadDateTimePicker();
          Date.ID = "AppDate" + i.ToString();
          values.text + = values.text + Date.SelectedDate.Value.ToString();
}
 this is not working ?
0
kreddy01
Asked:
kreddy01
1 Solution
 
amit_gCommented:
You are creating a new RadDateTimePicker at runtime. They have no association with the one that you have on the page. You have not shown the aspx side but the code should be something like this

for(i=0;i<n;i++)
{
          RadDateTimePicker Date;
          Date = (RadDateTimePicker) Page.FindControl("AppDate" + i.ToString());
          //Make sure Date is not null here
          values.text + = values.text + Date.SelectedDate.Value.ToString();
}

Page.FindControl could be something different if your date pickers are not directly in the page.
0
 
kreddy01Author Commented:
THANK YOU VERY MUCH IT WORKED LIKE MAGIC
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now