This is a migrated thread and some comments may be shown as answers.
Dynamic RadDateTimePicker
6 Answers 59 Views
This is a migrated thread and some comments may be shown as answers.
Prava kafle
Top achievements
Rank 1
Prava kafle asked on 17 Feb 2012, 09:28 PM
Hi,

Dynamic RadDateTimePicker doesnot show DatePicker and Time Picker Buttons, It just displays a text box. How can I make these buttons visible on  initial page load. 

These controls pop up only when I hover to the right of textbox.

Thanks,
Prava

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 20 Feb 2012, 10:02 AM
Hello,

I tried the same scenario in the version 2011.2.915.35 which worked as expected. Here is the sample code.
C#:
protected void Page_Load(object sender, EventArgs e)
{
    RadDateTimePicker RadDateTimePicker1 = new RadDateTimePicker();
    RadDateTimePicker1.ID = "RadDatePicker1";
    form1.Controls.Add(RadDateTimePicker1);
}

-Shinu.
0
Prava kafle
Top achievements
Rank 1
answered on 22 Feb 2012, 10:44 PM
Hi Shinu,
I have same code like yours but it does not show these controls on right side of Textbox. These controls display on hovering and when I set it, it doesnot persist the value on postback. On postback I get 1900.........
Can you provide me a small sample where RadDateTimePicker is added dynamically and when date and time selected by user causes a post back to  update a label  with that  datetime.
0
Princy
Top achievements
Rank 1
answered on 23 Feb 2012, 06:45 AM
Hello,

Here is the sample code that I tried.
C#:
RadDateTimePicker RadDateTimePicker1 = new RadDateTimePicker();
Label Label1 = new Label();
 protected void Page_Load(object sender, EventArgs e)
  {
    RadDateTimePicker1.ID = "RadDateTimePicker1";
    RadDateTimePicker1.AutoPostBack = true;
    RadDateTimePicker1.SelectedDateChanged += new Telerik.Web.UI.Calendar.SelectedDateChangedEventHandler(RadDateTimePicker1_SelectedDateChanged);
    form1.Controls.Add(RadDateTimePicker1);
    Label1.ID = "Label1";
    form1.Controls.Add(Label1);
  }
void RadDateTimePicker1_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
  {
    string s = RadDateTimePicker1.SelectedDate.ToString();
    Label1.Text = s;
  }

Thanks,
Princy.
0
Prava kafle
Top achievements
Rank 1
answered on 23 Feb 2012, 08:23 PM
Hi Shinu,
I forgot to add skin to RadDateandTimePicker Control and once I added it, Pop Up Button reappeared and my problem was solved.

I have another question related to RadDatePicker Control. On ChildCreated  event, I would like to add a button control  called"SET CURRENT TIME", clicking this button will set RadDateTimePicker1.selecteddateandtime  = current dateandtime.

I need this functionality because I am dynamically creating a RadDatepicker control in nested grid's edit item template.

Thank you very much for your effort. 
Prava
0
Princy
Top achievements
Rank 1
answered on 24 Feb 2012, 05:04 AM
Hello,

Try the following code.
C#:
RadDateTimePicker RadDateTimePicker1 = new RadDateTimePicker();
protected void Page_Load(object sender, EventArgs e)
 {
   RadDateTimePicker1.ID = "RadDateTimePicker1";
   RadDateTimePicker1.ChildrenCreated += new EventHandler(RadDateTimePicker1_ChildrenCreated);
   form1.Controls.Add(RadDateTimePicker1);
 }
void RadDateTimePicker1_ChildrenCreated(object sender, EventArgs e)
 {
   Button Button1 = new Button();
   Button1.ID = "Button1";
   Button1.Text = "SET CURRENT TIME";
   form1.Controls.Add(Button1);
   Button1.Click += new EventHandler(Button1_Click);
 }
void Button1_Click(object sender, EventArgs e)
 {
   RadDateTimePicker1.SelectedDate = System.DateTime.Now;
 }


Thanks,
Princy.
0
Prava kafle
Top achievements
Rank 1
answered on 24 Feb 2012, 10:39 PM
Hi,

It did the trick, thanks Princy!

Regards,
Prava
Asked by
Prava kafle
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Prava kafle
Top achievements
Rank 1
Princy
Top achievements
Rank 1
Share this question
or