You can use the following code :
function CheckAll(header,gridView)
{
id = gridView.id;
var rowCount = gridView.firstChild.childNodes.length;
for(var i=2;i<rowCount+1;i++)
{
if(i<10)
controlId = id+"_ctl0"+i;
else
controlId = id+"_ctl"+i;
document.getElementById(controlId+'_chkPost').checked = header.checked;
}
}
The parameters header will be the CheckBox in the Grid Header Column and gridView is your Grid Object.
Hope this helps.