悟生慧

 

CheckBox全选或全不选

<ASP:TEMPLATECOLUMN visible="False" sortexpression="demo" headertext="ID"> 
<ITEMTEMPLATE> 
<ASP:LABEL text=’<%# DataBinder.Eval(Container.DataItem, "ArticleID")%>’ runat="server" width="80%" id="lblColumn" /> 
</ITEMTEMPLATE> 
</ASP:TEMPLATECOLUMN> 

<ASP:TEMPLATECOLUMN headertext="选中"> 
<HEADERSTYLE wrap="False" horizontalalign="Center"></HEADERSTYLE> 
<ITEMTEMPLATE> 
<ASP:CHECKBOX id="chkExport" runat="server" /> 
</ITEMTEMPLATE> 
<EDITITEMTEMPLATE> 
<ASP:CHECKBOX id="chkExportON" runat="server" enabled="true" /> 
</EDITITEMTEMPLATE> 
</ASP:TEMPLATECOLUMN> 

后台代码

protected void CheckAll_CheckedChanged(object sender, System.EventArgs e) 

//改变列的选定,实现全选或全不选。 
CheckBox chkExport ; 
if( CheckAll.Checked) 

foreach(DataGridItem oDataGridItem in MyDataGrid.Items) 

chkExport = (CheckBox)oDataGridItem.FindControl("chkExport"); 
chkExport.Checked = true; 


else 

foreach(DataGridItem oDataGridItem in MyDataGrid.Items) 

chkExport = (CheckBox)oDataGridItem.FindControl("chkExport"); 
chkExport.Checked = false; 


posted on 2010-07-14 16:44  悟生慧  阅读(205)  评论(0编辑  收藏  举报

导航