I'm working on an ASP.NET application using VB.NET for server side code.
I have a GridView listing a bunch of stuff. Above the GridView I have a checkbox named "ChkBx_SelectAl l". If this checkbox is checked, all of the rows in the GridView are checked, if this checkbox is unchecked, all of the rows in the GridView are unchecked.
This checking/unchecking of the checkboxes in the GridView is handled by a JavaScript method:
[code=javascript]
function checkAllCheckbo xes(idOfControl lingCheckbox,gr idViewClientID)
{
var grid = document.getEle mentById(gridVi ewClientID);
var cell;
if (grid.rows.leng th > 0)
{
for (i=0; i<grid.rows.len gth; i++)
{
cell = grid.rows[i].cells[0];
for (j=0; j<cell.childNod es.length; j++)
{
if (cell.childNode s[j].type =="checkbox")
{
cell.childNodes[j].checked = document.getEle mentById(idOfCo ntrollingCheckb ox).checked;
}
}
}
}
}[/code]
This method is passed the ClientID of the "ChkBx_SelectAl l" checkbox, and sets all of the checkboxes in the GridView (whose ClientID is passed into this method as well) to match the "ChkBx_SelectAl l" checkbox.
All is well and happy!
Except......... .....after Unchecking all of the CheckBoxes in my GridView (via the JavaScript method) and then I click a any checkbox(es) in the GridView, that CheckBox is not marked as checked when I'm determining which GridView checkboxes are checked on the server.
If I remove this code and manually uncheck everything by hand, then check any checkbox(es) everything is fine.
Does anyone know why this JavaScript method is forcing my GridView to act in this way?
-Frinny
I have a GridView listing a bunch of stuff. Above the GridView I have a checkbox named "ChkBx_SelectAl l". If this checkbox is checked, all of the rows in the GridView are checked, if this checkbox is unchecked, all of the rows in the GridView are unchecked.
This checking/unchecking of the checkboxes in the GridView is handled by a JavaScript method:
[code=javascript]
function checkAllCheckbo xes(idOfControl lingCheckbox,gr idViewClientID)
{
var grid = document.getEle mentById(gridVi ewClientID);
var cell;
if (grid.rows.leng th > 0)
{
for (i=0; i<grid.rows.len gth; i++)
{
cell = grid.rows[i].cells[0];
for (j=0; j<cell.childNod es.length; j++)
{
if (cell.childNode s[j].type =="checkbox")
{
cell.childNodes[j].checked = document.getEle mentById(idOfCo ntrollingCheckb ox).checked;
}
}
}
}
}[/code]
This method is passed the ClientID of the "ChkBx_SelectAl l" checkbox, and sets all of the checkboxes in the GridView (whose ClientID is passed into this method as well) to match the "ChkBx_SelectAl l" checkbox.
All is well and happy!
Except......... .....after Unchecking all of the CheckBoxes in my GridView (via the JavaScript method) and then I click a any checkbox(es) in the GridView, that CheckBox is not marked as checked when I'm determining which GridView checkboxes are checked on the server.
If I remove this code and manually uncheck everything by hand, then check any checkbox(es) everything is fine.
Does anyone know why this JavaScript method is forcing my GridView to act in this way?
-Frinny
Comment