Reputation: 911
I have an asp.net gridview with one column as a template filed with a panel with some controls like textbox and dropdown list. So, onclick, with js I can give the value of a cell by row and column, but in this panel column how can I get the inner elements?
function t3(tab, element, NParents, col)
{
//alert("t3")
var grd = document.getElementById(tab);
if (grd != null)
{
var row = element
for (i = 0; i < NParents; i++)
{
row = row.parentNode
}
alert(grd.rows[row.rowIndex].cells[col].innerHTML)
}
}
innerHtml give me the HTML of the panel, now how can I find its elements?
Upvotes: 1
Views: 3228
Reputation: 68393
but in this panel column how can i get the inner elements?
You can use querySelector
to query the DOM element
var cell = grd.rows[row.rowIndex].cells[col];
var textbox = cell.querySelector( "input[type='text']" ); //will return input box inside the text
var select = cell.querySelector( "select" ); //will return dropdown inside the text
Upvotes: 2