checkbox 全选的使用

     1

for(int i=0;i<this.dgWaitDraw.Items.Count;i++)
    {
    
     if((this.dgWaitDraw.Items[i].Cells[8].FindControl("cbDraw") as CheckBox).Checked)
     {
      partID=this.dgWaitDraw.Items[i].Cells[0].Text.Trim().ToString();
      getId=this.Request["getID"].ToString();
      iFactQty=int.Parse(this.dgWaitDraw.Items[i].Cells[4].Text.Trim().ToString());
      err=BLL.BLL.zh.ProjectOprate.updateDrawByPartIDAndDrawID(partID,getId,iFactQty,db);
      if(err!=0)
      {
       MessageBox.Show(this.Page,"领料失败!");
       tran.Rollback();
       return;
      }
     }
    }

 

2

<HeaderTemplate>
<INPUT id=chkAll onclick="chk(this,'dgWaitDraw')" type=checkbox>全选
</HeaderTemplate>

<ItemTemplate>
<asp:CheckBox id=cbDraw runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>

 

3      <script language="javascript">
   function printpage(myDiv)
   {
    //var strResult=window.confirm("确认用Word打印吗?");
    var strResult=true;
    if(strResult)
    {
     
     var newstr = document.all.item(myDiv).innerHTML;
     var oldstr = document.body.innerHTML;
     document.body.innerHTML = newstr;
     window.print();
     document.body.innerHTML = oldstr;
    }
   }
   
  
  function chk(chk,id)
  {
   var oEvent = document.all(id);
   var chks = oEvent.getElementsByTagName("INPUT");
   for(var i=0; i<chks.length; i++)
   {
    if(chks[i].type=="checkbox")
    chks[i].checked=chk.checked;
   }
  }
  </script>
          

posted @ 2008-07-24 15:10  大树2  阅读(155)  评论(0编辑  收藏  举报