Click here to Skip to main content
15,896,367 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I got error when try to perform operation on grideview rowupdating

C#
Convert.ToDateTime(((TextBox)(grdBookDetails.Rows[e.RowIndex]
.FindControl("TextBox1")))
.ToString());


Please give me suggetion
Posted
Updated 8-Feb-16 7:15am
v2
Comments
Patrice T 8-Feb-16 12:00pm    
Which error ? !
Richard Deeming 8-Feb-16 12:15pm    
If your error starts with:
The string was not recognized as a valid DateTime.
or:
String was not recognized as a valid DateTime.
then your TextBox does not contain a valid DateTime value.

If you're getting a different error, then you need to tell us what it is.

1 solution

Depending on Globalization[^], the string format of date may differ.

You should use DateTime.TryParse(String, IFormatProvider, DateTimeStyles, DateTime)[^] method. Follow the link to find an example.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 8-Feb-16 14:16pm    
5ed.
—SA
Maciej Los 8-Feb-16 14:18pm    
Thank you, Sergey.

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