<asp:DetailsView...
<asp:TemplateField HeaderText="My CheckBox" SortExpression="DataID" >
<InsertItemTemplate>
<asp:CheckBox ID="T01cbx" runat="server" Visible ="false" Checked='<%# Bind("DataID") %>' AutoPostBack="True" " />
</InsertItemTemplate>
</asp:TemplateField>
I want give an ID or Name for the above TemplateField and access it from the code behind. Is there anyway to find the TemplateField by giving and ID or Name? This is inside a DetailView.
You could use LINQ to get a TemplateField
by it's HeaderText
:
TemplateField cbField = DetailsView1.Fields.OfType<TemplateField>()
.Where(f => f.HeaderText == "My CheckBox")
.FirstOrDefault();