79747379

Date: 2025-08-26 22:41:56
Score: 1
Natty:
Report link

I added the DataKeyNames attribute to the GridView to ensure unique identifiers for each row are properly managed. Then, I used the null-conditional operator (?.) when accessing the TextBox controls, like this: string NumEmpleados = (row.FindControl("TextNumEmpleado") as TextBox)?.Text;. This way, if the TextBox is not found, the code won’t try to access the .Text property and will return null instead, avoiding the exception.

Reasons:
  • Has code block (-0.5):
  • Single line (0.5):
  • Low reputation (1):
Posted by: Gleidi