简体   繁体   中英

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 asp.net 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;
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM