Solution when cannot FindControl in EditItemTemplate in ASP.NET 2

If you get this ASP.NET error message then you need to call ‘FindControl’ from your GridViews ‘DataBound’ or ‘RowDataBinding’ event methods/subs. This is because the controls within the template are not created until the row of the gridview is databound.

Eg. If you are trying to call ‘FindControl’ from ‘PageLoad’ then the controls from the template cannot be found as they do not yet exist.

Leave a Reply

Your email address will not be published. Required fields are marked *