Praveen Venugopal

Praveen Venugopal

  • NA
  • 127
  • 76.3k

Format exception occured while converting a string to datetime

Aug 19 2008 12:05 AM

Hello There!,

             I got an format exception when tried to convert a string to datetime .Actually the string was in correct structure to convert it to datatime ,it was "8/18/08 10.00am"

the code is

string START_TIME =((DataGrid1.Items[i].Cells[1].Text) + " " + (DataGrid1.Items[i].Cells[5].FindControl("Start_Time") as TextBox).Text);

i had populated a datagrid cell with month/date/year like

 DateTime Crnt_Time =DateTime.Now;
        int  day = Crnt_Time.Day;
        int mnth = Crnt_Time.Month;
        int yr = Crnt_Time.Year;
        string  Today = day + "/" + mnth + "/" + yr;

and i have a text box column in my datagrid to enter hours.

when i enter "Hours"in that text box cell in datagrid it should be tied up with the month/date/year value and stored in a local variable


Could you please tell me a solution for this?


Answers (1)