I have table in which have two column of INTIME and OUTtime
Empid |
INTIME |
OUT TIME |
1001 |
|
2018-11-11 08:00pm |
1002 |
2018-11-11 08:00am |
|
when i pass null value into table it raising exception String was not recognized as a valid DateTime.
on page loading
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
TextBox txtEntryDate = e.Row.FindControl("txtEntryDate") as TextBox;
TextBox txtEndDate = e.Row.FindControl("txtEndDate") as TextBox;
DateTime startDate = Convert.ToDateTime(txtEntryDate.Text);
DateTime endDate = Convert.ToDateTime(txtEndDate.Text);
TextBox txtHours = e.Row.FindControl("txtHours") as TextBox;
Behind Button
protected void TimeSpan(object sender, EventArgs e)
{
GridViewRow row = (sender as TextBox).NamingContainer as GridViewRow;
string txtINTIME= (row.FindControl("txtINTIME ") as TextBox).Text;
string txtTime= (row.FindControl("txtTime") as TextBox).Text;
TimeSpan timeSpan = Convert.ToDateTime(txtEndTime) - Convert.ToDateTime(txtINTIME );
please guide thanks