Hi all,
I am working on a GridView and there exist a Checkbox control .. iplaced another checkbox in header also i have written a javascript for selection of checkboxex fro e.g if you click on header checkbox that script will select all the child checkboxes its working fine but when that gridview doesn,t contain anything at that time this script is throwing an error i am sending the code also immidiately help needed
window.onload = function()
{
var gridv=document. getElementById( '<%= this.grvFinAppr oval.ClientID %>');
TotalChkBx = <%=this.grvFinA pproval.Rows.Co unt%>;
alert(TotalChkB x);
Counter = 0;
}
function HeaderClick(Che ckBox)
{
var TargetBaseContr ol = document.getEle mentById('<%= this.grvFinAppr oval.ClientID %>');
if(TargetBaseCo ntrol!=null) //not working
{
var TargetBaseContr ol = document.getEle mentById('<%= this.grvFinAppr oval.ClientID %>');
var TargetChildCont rol = "chkFinApproval ";
var Inputs = TargetBaseContr ol.getElementsB yTagName("input ");
for(var n = 0; n < Inputs.length; ++n)
if(Inputs[n].type == 'checkbox' && Inputs[n].id.indexOf(Tar getChildControl ,0) >= 0)
Inputs[n].checked = CheckBox.checke d;
Counter = CheckBox.checke d ? TotalChkBx : 0;
}
}
function ChildClick(Chec kBox)
{
var HeaderCheckBox = document.getEle mentById('<%= this.grvFinAppr oval.HeaderRow. FindControl("ch kCell").ClientI D %>');
if(HeaderCheckB ox!=null) //not working
{
if(CheckBox.che cked && Counter < TotalChkBx)
Counter++;
else if(Counter > 0)
Counter--;
if(Counter < TotalChkBx)
HeaderCheckBox. checked = false;
else if(Counter == TotalChkBx)
HeaderCheckBox. checked = true;
}
}
I am working on a GridView and there exist a Checkbox control .. iplaced another checkbox in header also i have written a javascript for selection of checkboxex fro e.g if you click on header checkbox that script will select all the child checkboxes its working fine but when that gridview doesn,t contain anything at that time this script is throwing an error i am sending the code also immidiately help needed
window.onload = function()
{
var gridv=document. getElementById( '<%= this.grvFinAppr oval.ClientID %>');
TotalChkBx = <%=this.grvFinA pproval.Rows.Co unt%>;
alert(TotalChkB x);
Counter = 0;
}
function HeaderClick(Che ckBox)
{
var TargetBaseContr ol = document.getEle mentById('<%= this.grvFinAppr oval.ClientID %>');
if(TargetBaseCo ntrol!=null) //not working
{
var TargetBaseContr ol = document.getEle mentById('<%= this.grvFinAppr oval.ClientID %>');
var TargetChildCont rol = "chkFinApproval ";
var Inputs = TargetBaseContr ol.getElementsB yTagName("input ");
for(var n = 0; n < Inputs.length; ++n)
if(Inputs[n].type == 'checkbox' && Inputs[n].id.indexOf(Tar getChildControl ,0) >= 0)
Inputs[n].checked = CheckBox.checke d;
Counter = CheckBox.checke d ? TotalChkBx : 0;
}
}
function ChildClick(Chec kBox)
{
var HeaderCheckBox = document.getEle mentById('<%= this.grvFinAppr oval.HeaderRow. FindControl("ch kCell").ClientI D %>');
if(HeaderCheckB ox!=null) //not working
{
if(CheckBox.che cked && Counter < TotalChkBx)
Counter++;
else if(Counter > 0)
Counter--;
if(Counter < TotalChkBx)
HeaderCheckBox. checked = false;
else if(Counter == TotalChkBx)
HeaderCheckBox. checked = true;
}
}
Comment