Programmatically change the date displayed in a DatePicker control?

1

I'm trying to display data from a field of a MySQL table in a DatePicker control. The code is as follows:

if (dataGridProdutos.SelectedIndex != -1)
{
    DateTime selectedDate;
    DataRowView selectedRecord = (DataRowView)dataGridProdutos.SelectedItem;
    selectedDate = (DateTime)selectedRecord.Row.ItemArray[2];
    dataNascTextBox.Text = selectedDate.Date.ToString("yyyy/MM/dd");
    dataNascDatePicker ????
    ...
}

How can I complete this line with dataNascDatePicker ?

    
asked by anonymous 01.12.2016 / 19:38

1 answer

1

I solved it like this:

DateTime selectedDate;
DataRowView selectedRecord = (DataRowView)dataGridProdutos.SelectedItem;
...
selectedDate = (DateTime)selectedRecord.Row.ItemArray[2];
dataNascDatePicker.SelectedDate = selectedDate;
...
    
01.12.2016 / 21:01