это, вероятно, проще, чем кажется.
сначала позволяет получить ссылку на представление сетки (отображается как таблица)
var t = document.getElementById('<% =GridView1.ClientID %>'); // use your gridview's id
тогда нам нужен список флажков
var tableInputs = t.getElementsByTagName('input'); // gets all input elements within the table
var chkList = []; // array where we'll keep track of marked checkboxes
for(var i=0; i<tableInputs.length; i++) {
// see if it's a checkbox and whether or not it's checked
if (tableInputs[i].type.match(/checkbox/i) && tableInputs[i].checked) {
// it is and it is, so add it to the list
chkList.push(tableInputs[i]);
}
}
теперь вы можете использовать флажки, чтобы получить ссылку на определенные строки и найти скрытые элементы
var fields;
var tr = null;
for (var j = 0; j < chkList.length; j++) {
// look up the heirarchy until you find the table row
tr = chkList[j].parentNode;
while (!tr.nodeName.match(/tr/i)) {
tr = chkList[j].parentNode;
}
// repeat the checkbox process for hidden fields
fields = tr.getElementsByTagName('input'); // all inputs in the same row
for (var k = 0; k < fields.length; k++) {
// see if it's a hidden field
if (fields[k].type.match(/hidden/i)) {
//TODO: here's a hidden field, do something
}
}
tr = null;
}
Я не всегда помню, когда имена тегов чувствительны к регистру, поэтому я по умолчанию использую регулярное выражение без учета регистра.