iterate through checkboxes issue

Hello everyone,

Hope you can help.
I have a project with: a datagrid, and the datagrid has some columns with values received from: a SQL database. the last column of the datagrid, is made of checkboxes.

ok so I have added some rows in SQL and they appeared in the datagrid as they should, together with the corresponding checkbox in the last column. my question is however how can I recognise the checkbox's status?

so theres checkboxes added dynamically (for each row inserted from SQL) so I cant target each of them by ID, i need some sort of iteration, like:

foreach(Checkbox in whatever...)
{
do..stuff
}
however the foreach does not work at all. the "whatever" should be the ID of the checkbox? it does not see my control in intellisense or how its called, which means it does not recognise the ID of the checkbox. so I dont know how to target them.

They were created from the aspx file like this:

<asp:datagrid ... >

<columns>
...
</columns>

<templatecolumn>
<itemtemplate>
<asp:Checkbox ID="blabla" runat="server" />
</itemtemplate>
</templatecolumn>

</asp:datagrid>

so when a new column is made from SQL it receives a checkbox too.
how do i target them?

Thank you in advance.
[1399 byte] By [novice_andrei] at [2007-11-20 10:48:14]
# 1 Re: iterate through checkboxes issue
You will need some JavaScripting for this...

var theInputs = table.getElementsByTagName('input');
for(i = 0; i < theInputs.length; i++){
if(theInputs[i].type == 'checkbox'){
// now you can grab each one.
}
}

If you have more than just those checkboxes, you can add a rel to the tag for identification.

var theInputs = table.getElementsByTagName('input');
for(i = 0; i < theInputs.length; i++){
if(theInputs[i].type == 'checkbox' && theInputs[i].rel == ':datagrid'){
// now you can grab each one.
}
}
PeejAvery at 2007-11-9 11:53:51 >
# 2 Re: iterate through checkboxes issue
Many thanks for this.

And is there a separate way to create a Delete Row option/button, if I decide not to use checkboxes?

Thank you.
novice_andrei at 2007-11-9 11:54:51 >
# 3 Re: iterate through checkboxes issue
You can assign an id to each <tr> and just delete it with deleteRow().
PeejAvery at 2007-11-9 11:56:00 >
# 4 Re: iterate through checkboxes issue
Thank you.
novice_andrei at 2007-11-9 11:56:57 >
# 5 Re: iterate through checkboxes issue
You're welcome. Good luck! :wave:
PeejAvery at 2007-11-9 11:57:56 >