CheckBox全选/全消设置和GridView自增序号

<script language="javascript" type="text/javascript">
 function CheckAllSelect()
 {
  var iRowCount=<%=grvApply.Rows.Count%>;
  
  var isCheckked = document.all.chkAllSelect.checked;
  
  for(i= 1;i<=iRowCount;i++ )
  {
   if(typeof(document.all.grvApply.rows(i).cells(0).children(0)) == "object")
   {                                                                      
    document.all.grvApply.rows(i).cells(0).children(0).checked = isCheckked;   
   }
  }
 }
</script>


<asp:GridView ID="grvApply" runat="server" SkinID="AlarmSkin" AutoGenerateColumns="False" OnRowDataBound="grvApply_RowDataBound" OnSelectedIndexChanging="grvApply_SelectedIndexChanging">
 <Columns>
  <asp:TemplateField HeaderText="&lt;input type='checkbox' id='chkAllSelect' title='全选/全消' onClick='CheckAllSelect();' &gt;">
   <ItemTemplate>
    <asp:CheckBox ID="chkBoxSelect" runat="server" />
   </ItemTemplate>
   <ItemStyle Width="20px" />
  </asp:TemplateField>
  <asp:TemplateField HeaderText="序号">
   <ItemTemplate>
    <asp:Label ID="Label1" runat="server" Text="<%# Container.DataItemIndex + 1%> "></asp:Label>
   </ItemTemplate>
   <ItemStyle Width="30px" />
  </asp:TemplateField>
  <asp:BoundField DataField="UserCode" HeaderText="用户名" />
  <asp:BoundField DataField="CourCode" HeaderText="课程编号" />
  <asp:BoundField DataField="CourName" HeaderText="课程名" />
  <asp:BoundField DataField="ApplyDate" HeaderText="申请日期" />
  <asp:BoundField DataField="ApplyStatus" HeaderText="申请状态" />
  <asp:TemplateField HeaderText="操作">
   <ItemTemplate>
    <asp:LinkButton ID="lblAccept" runat="server" CommandName="Select">受理</asp:LinkButton>
   </ItemTemplate>
  </asp:TemplateField>
 </Columns>
</asp:GridView>
posted on 2007-11-08 15:59  一路前行  阅读(650)  评论(0编辑  收藏  举报