The code listed below only works on the line, "string id = ((TextBox)DetailsView1.FindControl("TextBoxAttid")).Text;" regardless of the order I place the lines of code.
When I step through code and get to the other lines of code, I get the error message
"Object is not set to an instance of the object". The only object I think this error is referring to is the detailsview object. However that is not the error.
Thus can you tell me what object the code wants a new instance of?
if (DetailsView1.CurrentMode == DetailsViewMode.ReadOnly)
{
string id = ((TextBox)DetailsView1.FindControl("TextBoxAttid")).Text;
}
else if (DetailsView1.CurrentMode == DetailsViewMode.Edit)
{
string name1 = ((TextBox)DetailsView1.FindControl("TextBoxAttid")).Text;
string name3 = ((TextBox)DetailsView1.FindControl("Invalid_Form")).Text;
string name2 = ((TextBox)DetailsView1.FindControl("Prior_Cutoff_Date")).Text;
}