Need to store GridViewDateTimeValue into DateTimePicker
- by narmadha
Hi,I am Using Gridview in WindowsApplication.The following is my code:
if (dgvList.SelectedRows.Count > 0)
{
if (dgvList.SelectedRows[0].Cells != null)
{
DataGridViewRow dr = dgvList.CurrentRow;
txtMaterialName.Text = dr.Cells["MaterialName"].ToString();
dateTimePicker1.Text=DateTime.Parse(dr.Cells["PurchasedDate"].ToString()).ToString();
}
}
i need to store the PurchasedDate into DateTimePicker,But the Error
is "The string was not recognized as a valid DateTime. There is a unknown word starting at index 0."
Source="mscorlib"
StackTrace:
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at System.DateTime.Parse(String s)
at Godwins.EditStockAvailabilty.dgvList_SelectionChanged(Object sender, EventArgs e)
Can anyone help me,Thanks in advance.........