0

i have one combo box which has three values blue,green,yellow based on the value selected i need to have a rad date picker.

if i select blue and yellow from combo box i need to get the date picker UI in dd/MM/yyyy format.

if i select green from combo i need to get the date picker UI in MM/yyyy format.

I am new to this i don't know how to implement this and how to bind this later. please also let me know how to save date field in db for MM/yyyy format.Is it either smalldatetime datatype or string? Please suggest.

Thanks

Mohammad Javed
  • 328
  • 3
  • 13

1 Answers1

0

The easiest approach I can think of is to change the date format of the picker through the DateFormat and/or DisplayDateFormat properties (http://www.telerik.com/help/aspnet-ajax/calendar-dateinput-formatting-values.html) in the SelectedIndexChanged event of the combobox (http://www.telerik.com/help/aspnet-ajax/combobox-server-side-selectedindexchanged.html) Something like this should do the tridk

protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
    RadDatePicker1.DateInput.DisplayDateFormat = "dd / MM / yyyy";
    RadDatePicker1.DateInput.DateFormat = "dd / MM / yyyy";
}

On saving in a database - get the value of the datepicker and format it

DatePicker1.SelectedDate.Value.ToShortDateString();

or

String.Format("{0:MM/dd/yyyy}", picker.SelectedDate);

would be two basic examples

rdmptn
  • 5,413
  • 1
  • 16
  • 29