I am attempting to use the code-behind (Page_Load or PreRender) to set a date-time textbox in a DetailsView so that it defaults to a current date-time.
What I have attempted is (one of many variations):
protected void DetailsView2_PreRender(object sender, EventArgs e)
{
((TextBox)DetailsView2.FindControl("date_time")).Text =
DateTime.Now.ToString("d");
}
But all that I get is a 'NullReferenceException' error.
What I am doing wrong?