how to find a GridView label ClientID in js file

  • Thread starter Thread starter Deere
  • Start date Start date
D

Deere

I have an asp:label inside a GridView that I'm trying to put a value
into from a JS file.

I can successfully do it by looking at page source and then manually
constructing the following

document.getElementById("GridView1_ctl02_qty").innerText = " ( " +
mySplitResult[0] + " )"

But I can't get the server ID of the label by requesting it in the js
file.. I've tried several variations.....
document.getElementById('<%=GridView1.qty.ClientID%>')
document.getElementById('<%=GridView1.FindControl("qty").ClientID%>');
document.getElementById('<%=qty.ClientID%>')
document.getElementById('<%=GridView1$qty.ClientID%>')

I can though, put a value into a < input type ="text" id="qtyy">
inside Gridview by using.
document.getElementById("qtyy").value = " ( " + mySplitResult[0] +
" )"

can someone point out my error.. or where I need to look



thanks
 
I have your solution :

var controlId = '<%= ((TextBox)GridView1.FindControl("qty")).ClientID %>';
document.getElementById(controlId);

enjoy
 
Back
Top