Friday, August 23, 2013

how to find a control name in gridview inside template field

To find a control name in gridview inside template field

<asp:TemplateField HeaderText="Training Date">
<ItemTemplate>
<asp:Label ID="lblCourseDate" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>

write the following code in row databound of gridview

If e.Row.RowType = DataControlRowType.DataRow Or e.Row.RowType = ListItemType.AlternatingItem Or e.Row.RowType = ListItemType.Item  Then
Dim lblCourseDate As Label = e.Row.FindControl("lblCourseDate")
End If

No comments:

Post a Comment