Checkboxes in Datagrid

A

Aaron

I have found a script for selecting and deselcting all of the checkboxes in
a datagrid by using a master checkbox. This is similar to the hotmail or
yahoo mail checkbox which will allow you to select all of your emails using
the master checkbox at the top of the checkbox column:

<script>
function select_deselectAll (chkVal, idVal)
{
var frm = document.forms[0];
// Loop through all elements
for (i=0; i<frm.length; i++)
{
// Look for our Header Template's Checkbox
if (idVal.indexOf ('CheckAll') != -1)
{
// Check if main checkbox is checked, then select or deselect
datagrid checkboxes
if(chkVal == true)
{
frm.elements.checked = true;
}
else
{
frm.elements.checked = false;
}
// Work here with the Item Template's multiple checkboxes
}
else if (idVal.indexOf ('chkSelect') != -1)
{
// Check if any of the checkboxes are not checked, and then
uncheck top select all checkbox
if(frm.elements.checked == false)
{
frm.elements[1].checked = false; //Uncheck main select all
checkbox
}
}
}

}
</script>

I also have:
<asp:TemplateColumn Visible="False">
<HeaderTemplate>
<asp:CheckBox ID="CheckAll" OnClick="javascript: return
select_deselectAll (this.checked, this.id);"
runat="server" />
<font face="Webdings" color="white" size="4">a</font>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox id="chkSelect" OnClick="javascript: return
select_deselectAll (this.checked, this.id);" runat="server" />
</ItemTemplate>
</asp:TemplateColumn>

I get the underlined error for the OnClick event which says that there is no
attribute of OnClick for checkboxes, the page does run, but no selection of
checkboxes happens. If I change OnClick to OnCheckedChanged, the page fails
to load saying that javascript is not a memeber of ASP.Webform1_aspx.

What is the reason for failure here?

Thank you very much. I appreciate your time,
Aaron
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top