Akhter HUssain

Akhter HUssain

  • 682
  • 1.3k
  • 95.5k

String was not recognized as a valid DateTime.'

Sep 9 2019 8:04 AM
When i selecting row from gridview for editng and does not has date in date column then this exception is raising 
String was not recognized as a valid DateTime.'
 
  1. protected void Edit(object sender, EventArgs e)  
  2.         {  
  3.             using (GridViewRow row = (GridViewRow)((LinkButton)sender).Parent.Parent)  
  4.             {  
  5.                 txtEmpID.ReadOnly = true;  
  6.                 txtEmpID.Text = row.Cells[0].Text;  
  7.                 txtEmpName.Text = row.Cells[1].Text;  
  8.                 txtFahterName.Text = row.Cells[2].Text;  
  9.                 //ddlSecID.ClearSelection();  
  10.                 //ddlSecID.Items.FindByText(row.Cells[3].Text).Selected = true;  
  11.                 //txtjdate.Text = row.Cells[4].Text;  
  12.   
  13.                 ddlSecID.ClearSelection();  
  14.                 if (ddlSecID.Items.FindByText(row.Cells[3].Text) != null)  
  15.                 {  
  16.                     ddlSecID.Items.FindByText(row.Cells[3].Text).Selected = true;  
  17.                 }  
  18.                 txtjdate.Text = Convert.ToDateTime(row.Cells[4].Text).ToString("dd/MM/yyyy");  
  19.   
  20.                 txtldate.Text = Convert.ToDateTime(row.Cells[5].Text).ToString("dd/MM/yyyy");  
  21.   
  22.                 popup.Show();  
  23.             }  
 

Answers (4)