I have a Label control within a GridViewRow cell, that I need to access from the client side using Javascript. I can access the GridView row fine, but I can’t for the life of me work out how to access the Label within it.
Layout:
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="link_lbl" runat="server" Visible="false" Text='<%# BIND("link") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
Javascript:
var gridview = document.getElementById("<%= list_gv.ClientID %>");
for (i = 1; i < gridview.rows.length; i++) {
var label = gridview.rows[i].cells[0].?????
}
I’ve tried various things where the ????? is, but can’t get to the Label control to read from it!
Any ideas please?
Try this code
This will give you the first label text in cell[0].
You can also directly get by using label id.