2

I want to set the RadDatePicker value to a value retrieved from my database

I have this code

DateTime Podate = Convert.ToDateTime(da.GetDataKeyValue("PoDt"));
RadDatePicker.SelectedDate =Podate;

but when I run this program the DatePicker shows blank value

What should I do? Please help

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
sidhewsar
  • 136
  • 2
  • 8
  • 17

4 Answers4

3

Try likes this ,

  protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
     RadDatePicker.SelectedDate = 
     DateTime.Parse(da.GetDataKeyValue("PoDt").ToString());
        }
    }

If not working by this code , please check with

     RadDatePicker.SelectedDate = DateTime.Now;

If it work with this , you have to check your retrieve data da.GetDataKeyValue("PoDt") .
It may be in wrong datetime dataformat !

zey
  • 5,939
  • 14
  • 56
  • 110
1

only set the DbSelectedDate property on your telerik control as given below your work will be done :

      <telerik:RadDatePicker 
           ID="RDtbenddate" runat="server" 
           DateInput-ForeColor="#00CCFF" DateInput-ToolTip="End Date"
           DbSelectedDate='<%# Bind("JobClosingDate") %>' Width="250">
      </telerik:RadDatePicker>
Ketan
  • 81
  • 1
  • 2
  • 7
0

This works too:

RadDatePicker1.SelectedDate = (DateTime) Contact.Birthdate;
R B
  • 413
  • 3
  • 8
  • 19
0

Please not If you use RequiredFieldValidator

You must add Display="Dynamic" to RequiredFieldValidator

Otherwise date would not be displayed

Swati
  • 28,069
  • 4
  • 21
  • 41