Error while comparing date. Calendar control

10e5x

Member
Joined
Jun 29, 2012
Messages
14
Programming Experience
Beginner
I am trying to achieve highlighting dates in the calendar.

 Protected Sub Calendar1_DayRender(sender As Object, e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
For i As Integer = 0 To GridView1.Rows.Count - 1
            Dim stringDate = GridView1.Rows(i).Cells(0).Text
            If Date.Parse(stringDate) = e.Day.Date Then
                e.Cell.BackColor = System.Drawing.Color.LightGreen
                notTouched = False
            End If
Next

End Sub


But i am getting FormatException Error. String was not recognized as a valid DateTime. Btw i want my string format to be in date not datetime. 
Help me please.




 
Kinda pointless trying to pontificate on this if we don't know what the Text is that's being passed to the parse! If it's getting this error my guess is that it isn't in a recognised format.
 
Thanks Dunfiddlin, you are right. i solved it thanks. btw i still do no how to rep others or mark this thread as solution. mind teaching me? cuz new in forum. Btw i have another urgent problem(thread posted) mind taking a look? its about converting string to time(0) data type.

input: 10:30:00 (string)
desired output : 10:30:00 (time(0))
 
Back
Top