title: How to bind date from datagridview to datetime picker in c#?
body: <p>I have column name "Session" in table which store data as "2010-2014" etc format and i get this string from two date time pickers  as:</p>
  
  <pre><code>string dat = dateTimePicker1.Text + "-" + dateTimePicker2.Text;
  </code></pre>
  
  <p>i set datetimepicker property as Year only so it gave me result as when i selected dates
  "2010-2014" </p>
  
  <p>In Insertion this is working good but for updation i need to load this value back to date time pickers as  it e-g in datetimepicker1 text must be 2010 and in datetimepicker2 text must be 2014 according to my example. </p>
  
  <p>i made a lot of search on google and did this as:</p>
  
  <pre><code>                string str = row.Cells[5].Value.ToString();
              string first = str.Substring(0, str.IndexOf('-'));
              string second = str.Substring(str.IndexOf('-') + 1);
  
              dateTimePicker1.Text = Convert.ToDateTime(first).ToString();
              dateTimePicker2.Text = Convert.ToDateTime(second).ToString();
  </code></pre>
  
  <p>But it threw an error that:</p>
  
  <pre><code>String was not recognized as a valid DateTime
  </code></pre>
  
  <p>I am using c# windows app development.</p>
  
  <p>Any body has any idea where am i missing something?
  thanks in advance..</p>