Jason666 0 Newbie Poster

I have been going through the motions and still cannot seem to get this right. I have textboxes in a gridview that are populated from an access database. They are all datetime values. In the backend code, I am trying to loop through all those values and then apply conditional formatting. For some unknown reason I am unable to get the value from those textboxes in the gridview and when I do, they are seen by the app as string as opposed to datetime. Converting is futile as the same error, "String was not recognized as a valid DateTime." keeps popping up.

Any ideas on how to get values from a gridview textbox, and then convert them from a string to a datetime format?

Here is the code thus far...

for (int p = 0; p < rowscount; p++)
 {
     var myLabel2 = (TextBox)GridView1.Rows[p].Cells[0].FindControl("Label2");
     var myLabel4 = (TextBox)GridView1.Rows[p].Cells[0].FindControl("Label4");

     DateTime start = Convert.ToDateTime(myLabel2.Text).Date;
     DateTime now = DateTime.Now.Date;
     DateTime end = Convert.ToDateTime(myLabel4.Text).Date;

     if (now >= start && now <= end)
     {
         myLabel2.BackColor = Color.Chartreuse;
         myLabel4.BackColor = Color.Chartreuse;
         myLabel7.BackColor = Color.Chartreuse;
         myLabel9.BackColor = Color.Chartreuse;
     }
     else
     {
         myLabel2.BackColor = Color.White;
         myLabel4.BackColor = Color.White;
         myLabel7.BackColor = Color.White;
         myLabel9.BackColor = Color.White;
     }
 }

Thanks in advance