Click here to Skip to main content
15,891,811 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have this in rowdatabound

if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[6].Text = Convert.ToDateTime(e.Row.Cells[6].Text).ToShortDateString();
}

and its work when calling the gridview but system crashes when editing??!!!

anythought?
Posted

1 solution

Well, hard coded values like this are never good. Also, I guess when you edit, the value starts empty. NEVER use Convert. methods if you can help it, and if you must, use a try/catch. Did you debug this, to work out what the error is ? You didn't even post the error, which is far from helpful, but I'd say you just need to move that cell text to a string, check if it's empty, and if not, then TRY to parse it ( that is, allow for an exception when you know it's possible one will be thrown )
 
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