判断datagrid中checkbox选中的个数

public int pdxzs(DataGrid dg1)
  {
   int checkcount=0;
   for(int i=0;i<dg1.Items.Count;i++)
   {
    if(((System.Web.UI.HtmlControls.HtmlInputCheckBox)dg1.Items[i].FindControl("xuanze")).Checked==true)
     checkcount++;
   }
   return checkcount;
  }

//调用

if(pdxzs(datagrid1)==0)
{
   Response.Write("<script>alert('未选中任何职位!')</script>");
    return;
}
posted @ 2007-07-04 09:57  MangaGo  阅读(383)  评论(0编辑  收藏  举报