Check items in GridView with JavaScript

  • Thread starter Thread starter McGeeky
  • Start date Start date
M

McGeeky

Hi. Is it possible to iterate through the items in a GridView using
JavaScript on the client?
 
You can iterate through the visible items (represented by the
DomElement tableRow) with the following snippet...

<script>
var tableElement = document.getElementById('idOfTable');
for (var i=0;i<tableElement.rows.count;i++){
var rowElem = tableElements.rows;
for (var x=0;x<rowElem.cells.count;x++){
var cell = rowElem.cells[x];
//cell is a reference to the cell object from where you can
get the checkbox element
}
}
</script>

Regards,
Tasos
 
Great! Thanks for that. Is there are programmatic way to embed the ID of the
table in to the HTML file rather than hard coding it?

You can see that I am fairly new to this!

Thanks.

--
McGeeky
http://mcgeeky.blogspot.com


Tasos Vogiatzoglou said:
You can iterate through the visible items (represented by the
DomElement tableRow) with the following snippet...

<script>
var tableElement = document.getElementById('idOfTable');
for (var i=0;i<tableElement.rows.count;i++){
var rowElem = tableElements.rows;
for (var x=0;x<rowElem.cells.count;x++){
var cell = rowElem.cells[x];
//cell is a reference to the cell object from where you can
get the checkbox element
}
}
</script>

Regards,
Tasos
 
<%=dataGridInstance.ClientID%>

.... in the javascript ...
Great! Thanks for that. Is there are programmatic way to embed the ID of the
table in to the HTML file rather than hard coding it?

You can see that I am fairly new to this!

Thanks.

--
McGeeky
http://mcgeeky.blogspot.com


Tasos Vogiatzoglou said:
You can iterate through the visible items (represented by the
DomElement tableRow) with the following snippet...

<script>
var tableElement = document.getElementById('idOfTable');
for (var i=0;i<tableElement.rows.count;i++){
var rowElem = tableElements.rows;
for (var x=0;x<rowElem.cells.count;x++){
var cell = rowElem.cells[x];
//cell is a reference to the cell object from where you can
get the checkbox element
}
}
</script>

Regards,
Tasos
Hi. Is it possible to iterate through the items in a GridView using
JavaScript on the client?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top