Find Label Inside Gridview using Javascript

Rajesh_Kumar
Posted by Rajesh_Kumar under JavaScript category on | Points: 40 | Views : 5812
function FetchLabel(button) 
{
var row = button.parentNode.parentNode;
var label = GetChildControl(row, "lbl_employee_first_name");
alert(label.innerHTML);
return false;
};

function GetChildControl(element, id)
{
var child_elements = element.getElementsByTagName("*");
for (var index = 0; index <=child_elements.length-1;index ++)
{
if (child_elements[index].id.indexOf(id) != -1)
{
return child_elements[index ];
}
}
};


Inside Gridview,place Button and Label control:
<asp:Button Text="Fetch" runat="server" OnClientClick="return FetchLabel(this);" />
<asp:Label ID="lbl_employee_first_name" runat="server" Text = '<%# Eval("employee_first_name") %>'></asp:Label>

Comments or Responses

Login to post response