This codes will help you with your datagrid activities.
You have to add a CheckBox to datagrid.
HTML Code
this html tag adds a checkbox to header 1-add asp:TemplateColumn tag
2-add HeaderTemplate tab
3-add input tag with id=checkAll,type=checbox,onclick=DGSelectOrUnselectAll('DataGrid1',this,'chkDel')
this html tag adds checkbox to datagrid 1-add ItemTemplate tag
2-add asp checkbox control within ItemTemplate tag with id=chkDel,RunAt=server
JavaScript codes:Add these js code in
this is to select or unselect the datagrid check boxes
function DGSelectOrUnselectAll(grdid,obj,objlist){
//this function decides whether to check or uncheck all
if(obj.checked)
DGSelectAll(grdid,objlist)
else
DGUnselectAll(grdid,objlist)
}
//----------
function DGSelectAll(grdid,objid){
//.this function is to check all the items
var chkbox;
var i=2;
chkbox=document.getElementById(grdid +
'__ctl' + i + '_' + objid);
while(chkbox!=null){
chkbox.checked=true;
i=i+1;
chkbox=document.getElementById(grdid +
'__ctl' + i + '_' + objid);
}
}//--------------
function DGUnselectAll(grdid,objid){
//.this function is to uncheckcheck all the items
var chkbox;
var i=2;
chkbox=document.getElementById(grdid +
'__ctl' + i + '_' + objid);
while(chkbox!=null){
chkbox.checked=false;
i=i+1;
chkbox=document.getElementById(grdid +
'__ctl' + i + '_' + objid);
}
}
If you have question please email me at johnstalley@live.com
My name is Talley Ouro,Developer in Raleigh,NC
No comments:
Post a Comment