I've created the GridView with templates like the following:
<asp:TemplateField SortExpression="Date1">
<AlternatingItemTemplate>
<asp:CheckBox ID="chkSelected" runat="server" />
</AlternatingItemTemplate>
</asp:TemplateField>
<asp:TemplateField SortExpression="Date2">
<AlternatingItemTemplate>
<asp:CheckBox ID="chkSelected" runat="server" />
</AlternatingItemTemplate>
</asp:TemplateField>
On runtime it cause the error:
Message : Multiple controls with the same ID 'chkSelected' were found. FindControl requires that controls have unique IDs.
Type : System.Web.HttpException, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Message : Multiple controls with the same ID 'chkSelected' were found. FindControl requires that controls have unique IDs.
Source : System.Web
ErrorCode : -2147467259
Stack Trace : at System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls)
at System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls)
at System.Web.UI.Control.EnsureNamedControlsTable()
at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
at System.Web.UI.Page.FindControl(String id)
at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
The problem explained on forum "GridViewRow is the naming container in GridView, not individual TableCell.
It causes expectation, that generated cell is naming container, which is not correct.
Because template is not derived from Control, specifying INamingContainer interface has no effect and should be removed.
Similar templates are described in