Bhavna Chaudhri

Bhavna Chaudhri

  • 1.5k
  • 531
  • 6.3k

Null reference exception on Edit

Nov 26 2020 12:25 PM
I have an Asp.Net application , on Edit click on Gridview a popup is opened , but as some columns may be null i am getting error on assignment.
  1. var teacher= from t in db.Teachers.ToList()  
  2.                         select new   
  3.                         {  
  4.                          Name=t.UserName,  
  5.                          FirstName=t.FirstName,  
  6.                          LastName=t.LastName,  
  7.                          Email=t.Email,  
  8.                          Lab=t.Lab  
  9.                         }  
  10.   
  11.   txtUserName.Text=teacher.Name;  
  12.   txtFirstName.Text=teacher.FirstName;  
  13.    txtLastName.Text=teacher.LastName; // here i am getting error  
  14.   txtEmail.Text=teacher.Email;  
  15.    txtLab.Text=teacher.Lab;  
  16.   
  17.                            
 

Answers (1)