Click here to Skip to main content
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 Mathew Soji 334
1 Maciej Los 295
2 BillWoodruff 290
3 Afzaal Ahmad Zeeshan 257
4 DamithSL 225
0 OriginalGriff 6,369
1 Sergey Alexandrovich Kryukov 5,973
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,045


Advertise | Privacy | Mobile
Web04 | 2.8.1411019.1 | Last Updated 22 Oct 2014
Copyright © CodeProject, 1999-2014
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