Click here to Skip to main content
15,891,682 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
var ParentGrid = document.getElementById("<%= gvParentGrid.ClientID %>");


C#
var chidgridVal1 = document.getElementById('ctl00_MainContent_gvParentGrid_ctl02_gvChildGrid');
                  var chidgridVal2 = document.getElementById('ctl00_MainContent_gvParentGrid_ctl03_gvChildGrid');
                  var chidgridVal3 = document.getElementById('ctl00_MainContent_gvParentGrid_ctl04_gvChildGrid');


without using 'ctl00_MainContent_gvParentGrid_ctl02_gvChildGrid' how can i get the id of control for grid
Posted
Updated 5-Aug-13 23:16pm
v2
Comments
Thanks7872 6-Aug-13 5:17am    
You have already been answered here http://www.codeproject.com/Questions/631944/How-to-get-Id-of-child-Gridview-inside-Parent-grid and you have also accepted the answer and commented as working.

1 solution

You can find by use JQuery
JavaScript
$("#GridviewID tbody").find('tr').each(function (i) { 
   var text = $(this).find("input[type='input']")[0];
});

The above loop will find each row of grid and the below code is to find the first textbox in the row.
JavaScript
// if u need nth textbox of the row  give nth-1 as the index 
var text = $(this).find("input[type='text']")[0]


or u can write as below
JavaScript
var firstRow = $("#GridviewID tbody").find('tr')[0];
var firstTextbox $(FirstRow)..find("input[type='text']")[0];
 
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