Omesh Omesh - 8 months ago 33
ASP.NET (C#) Question

How to display a string value in a Calendar control?

I have a string value which is in DateTime format where I have captured from a different Calendar control; How can I display that value in a Calendar control in a form?

string dateTo = dsDept.SelectedRow.Cells[3].Text;
string datefrom = dsDept.SelectedRow.Cells[2].Text;

Two string values are selected from a data grid view. I need these two dates to be displayed in two Calendar controls.


You need to convert that to DateTime and then assign to calendar SelectedDate property like

  DateTime capturedDate;
  if(DateTime.TryParse(dateTo, out capturedDate))
       Calendar1.SelectedDate = capturedDate;