All I need to do is, using Javascript on the client side, go through the rows in a data grid, see if the checkbox is check then look at another column in that row to see if it has a value, and then count the checked items. I know it sounds silly, but we are trying to limit the number of checkboxes actually selected so that everything selected gets printed. If too many are selected, the reporting tool just doesn't print ANYTHING (I'll save THAT for another post ;~)
Here's the code I have so far:
function CheckboxCheckedChanged() {
var grid = document.getElementById('<%= FormView1.FindControl("rgContactsDisplay").ClientID %>');
var inputElements = grid.get_dataItems(); //THIS IS THE LINE THAT DOESN'T WORK
var index;
var MAX = 10;
var remaining;
var hldCompany = null;
for (index = 0; index < inputElements.length; index++) {
if (inputElements[index].id.indexOf("chkContacts") != -1) {
if (inputElements[index].checked == true) {
// If First row
if (hldCompany == null) {
hldCompany = grid.rows[index].cells[2] //grid.row(2);
}
//If I already have this company, just add 1 for the contact if it’s there
if (hldCompany == grid.rows[index].cells[2]) {
if (grid.rows[index].cells[3] != null &&
grid.rows[index].cells[3] != ' ') {
remaining = remaining + 1;
break;
}
}
else {
hldCompany = grid.rows[index].cells[2];
if (grid.rows[index].cells[3] != null &&
grid.rows[index].cells[3] != ' ') {
remaining = remaining + 2;
break;
}
else {
remaining = remaining + 1;
break;
}
}
}
}
}
remaining = MAX - remaining;
if (remaining < 0) {
alert("Too many contacts selected for printing");
}
}
I've tried a number of different things for the line that doesn't work, but so far the only thing I'm getting is that the "object doesn't support" the method...or errors similar.
I was able to finally get an object from the line above that so I THINK I have a grid to process.
Thanks for any help...
Rich