Click here to Skip to main content
15,878,959 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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...
XML
<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
C#
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
Updated 5-Nov-12 22:27pm
v2
Comments
NAPorwal(8015059) 6-Nov-12 4:14am    
why u putting your lable inside table tag it would be easier if you format <itemtemplate> tag only
Yvonne192 6-Nov-12 4:17am    
i need both table and label inside gridview
Sanjay K. Gupta 6-Nov-12 4:32am    
But why you need both table and label

1 solution

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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900