Javascript to retrieve Gridview cell text

T

Tony WONG

This is a Label in ItemTemplate

i wish to use javascript to put <%# Eval("Organization") %> in a textbox

How can i take the text value of <%# Eval("Organization") %>?

put this - onmousedown="alert(<%# Eval("¥Ó½Ð¾÷ºc") %>)" ???

thanks for any ideas?

***********************
></asp:Label>
&nbsp;<asp:Label ID="Label2" runat="server" Text='<%# Eval("Department") %>'
</asp:Label>
 
T

Tony WONG

Thank you for your patient to listen my problem

I tried many solutions for a few hours and still fail
the problem is how to retrieve the label text in a itemTemplate of a
Gridview

***** asp.net *************
<ItemTemplate>
<asp:Label ID="LbOrg" runat="server" Text='<%# Eval("Org") %>'
onmousedown='SearchOrg();'></asp:Label>
</ItemTemplate>

try many ways, return error "LbOrg not declared"
****** javascript *********
var controlId = document.getElementById('<%=LbOrg.ClientID%>').text;
var controlId = document.getElementById('<%=LbOrg.ClientID%>').value;
var controlId = document.getElementById('<%=LbOrg.ClientID%>').innerText;
var controlId = document.getElementById('<%=LbOrg.ClientID%>').innerHTML;

********* html ******************
<span id="GridView1_ctl02_LbOrg" onmousedown="SearchOrg();">Organization
name</span>

i know there is a long solution by assigning index at rowdatabound, and
javascript retrieve parameter of the row index

but it seems asp.net solution is much shorter.

Grateful for any assistance. thx.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top