Click here to Skip to main content
11,410,118 members (63,138 online)
Rate this: bad
good
Please Sign up or sign in to vote.
Hi everyone..
I have a tircky question to ask..
I want to get the ID of the ASP control inside a table and the table is inside a gridview...
Here's the code to give you a better idea...
<asp:GridView ID="gvTest" runat="server">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <table width="100%">
                            <tr>
                                <td><asp:Label ID="lblTestLabel" runat="server"></asp:Label></td>
                            </tr>
                        </table>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
I have no problem getting the control inside a gridview and here's the code
function TestFunction(sender, e)
{
     var gridview = document.getElementById('gvTest.ClientID');
     var i = gridview.rows.length - 1;
     var node1 = gridview.rows[i].cells[1].children[0];
 }
But i need to put table inside gridview for formatting issues and when i did it, the controls are not accessible ....
So my question is how can i get the ID of the ASP label (in this case, lblTestLabel") in javascript??
Answers and suggestions are very much appreciated..
Posted 5-Nov-12 23:07pm
Edited 5-Nov-12 23:27pm
v2
Comments
Neelam Chandra (8015059) at 6-Nov-12 4:14am
   
why u putting your lable inside table tag it would be easier if you format tag only
Yvonne192 at 6-Nov-12 4:17am
   
i need both table and label inside gridview
Sanjay K. Gupta at 6-Nov-12 4:32am
   
But why you need both table and label

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi guys.. Problem solved now using :
var value = $('[id$=lblTestLabel]').val(); 
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 229
1 OriginalGriff 140
2 Maciej Los 138
3 Sascha Lefévre 120
4 BillWoodruff 60
0 Sergey Alexandrovich Kryukov 8,771
1 OriginalGriff 6,905
2 Maciej Los 3,390
3 Abhinav S 3,248
4 Peter Leow 3,059


Advertise | Privacy | Mobile
Web04 | 2.8.150414.5 | Last Updated 22 Oct 2014
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100