1.In your first code block, you have stored in your
Session
the string value, of the converted
DataTime
value. Then in your second block you read that string and try to use a
DateTime
method (
AddSecond
) directly to the string, and this generate the error.
2.The solution is to store in the session the
DateTime
value and not the
string
(in your first code block).
StartTime = DateTime.Now.AddMinutes(lbltime.Text)
Session("time") = StartTime
Then in the second block to use it, by using unboxing, and reduce the to many ToString used like bellow:
CurrentTime = (DateTime)Session("time")
CurrentTime = CurrentTime.AddSeconds(-1)
lbltime.Text = CurrentTime.ToString("HH:mm:ss")