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?
Praveen VenugopalPosted Aug 19, 2008, 12:12 AM
Hi,
I solved it .First of all We have to enter hours in the format of hh:mm .We can make a validation scipt for that
and in the code behind ,
string START_TIME =((DataGrid1.Items[i].Cells[1].Text) + " " + (DataGrid1.Items[i].Cells[5].FindControl("Start_Time") as TextBox).Text)+":"+"00"; string END_TIME = ((DataGrid1.Items[i].Cells[1].Text) + " " + (DataGrid1.Items[i].Cells[6].FindControl("End_Time") as TextBox).Text) + ":" + "00";Parameters[3] =
Convert .ToDateTime (START_TIME);Parameters[4] =
Convert.ToDateTime(END_TIME);