Check items in GridView with JavaScript

M

McGeeky

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

Tasos Vogiatzoglou

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
 
M

McGeeky

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
 
T

Tasos Vogiatzoglou

<%=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

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top