Disable gridview column using javascript

Rajni.Shekhar
Posted by Rajni.Shekhar under JavaScript category on | Points: 40 | Views : 8210
//disable gridview column

function disableGVColumn(strGV, strColName) //gv id as string
{
var gridViewID=document.getElementById(gv);
var index=0;
for (i = 2; i <= gridViewID.rows.length + 1; i++){
if((i.toString()).length==1) //concatenate like 01, 02 if row length is less than 10
{
index="0" + i.toString();
}
else{
index=i.toString(); //else index of column would be 11.... on words
}
var colID = strGV + "_ctl" + index + "_" + strColName;
document.getElementById(colID).disabled = true;
}
}

you can also modified this function for all columns by using a loop for all column.
or you can also whole grid direct using grdID.disabled=true for a grid

Comments or Responses

Login to post response