在DataGrid中的头把所有复选框控件。

在DataGrid中的头把所有复选框控件。

            
             
              
             
            

               
               

            



            很简单的方法,就是用js实现:

页面:

AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False">

























后台代码:

private void dgUserList_PreRender(object sender, System.EventArgs e)
{
foreach (DataGridItem item in dgUserList.Controls[0].Controls)
{
if (item.ItemType == ListItemType.Header)
{
CheckBox chkAll=(CheckBox)item.FindControl("chkAll");
System.Text.StringBuilder strScript = new System.Text.StringBuilder(" \n");

if(!Page.IsClientScriptBlockRegistered("checkStatus"))
Page.RegisterClientScriptBlock("checkStatus",strScript.ToString());

chkAll.Attributes.Add("onclick","checkStatus()");
return;
}



tag:控件复选框电脑软件DataGrid

相关内容