Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to update grid column by timer .
need to count down time

catch error Addsecond on type string not found
THIS IS CODE https://gist.github.com/niwatpumkin/daa79edab4ffa08d4619[^]


help me pls
Posted
Comments
Raul Iloc 18-Sep-14 1:14am    
Did you try like I suggested?

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).
VB
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:
VB
CurrentTime = (DateTime)Session("time") 'unboxing from the value from the Session cache!
CurrentTime = CurrentTime.AddSeconds(-1)
lbltime.Text = CurrentTime.ToString("HH:mm:ss")
 
Share this answer
 
for variables StartTime and currentTime assign datetime to them don't convert tostring
so modify this lines of code
VB
StartTime = DateTime.Now.AddMinutes(lbltime.Text).ToString("HH:mm:ss")
CurrentTime = StartTime.ToString
----
CurrentTime = Session("time").AddSeconds(-1).ToString()



to be

VB
StartTime = DateTime.Now.AddMinutes(lbltime.Text)
CurrentTime = StartTime
----
CurrentTime = Session("time").AddSeconds(-1) 
 
Share this answer
 
Session("time") would need to be cast to a datetime
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900