导航

DataGrid全选与反选,删除弹出对话框

Posted on 2005-04-07 22:17  兰宝石.NET  阅读(1040)  评论(0编辑  收藏  举报

<%@ Page language="c#" Codebehind="MeetingList.aspx.cs" AutoEventWireup="false" Inherits="Rata.HCOAWEB.Form.MeetingRoomManager.MeetingList" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 <HEAD>
  <title>CarList</title>
  <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
  <meta content="C#" name="CODE_LANGUAGE">
  <meta content="JavaScript" name="vs_defaultClientScript">
  <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
  <LINK href="../../Css/Form.css" type="text/css" rel="stylesheet">
  <script src="../../JS/Main.js" type="text/javascript"></script>
  <script language="javascript">

   <!--
   
   // <summary>
   // 进行 DataGrid 的 全选/取消全选 控制
   // </summary>
   var checkFlag = true;
   function ChooseAll()
   {
    //if( !document.all("CheckAll").Checked ) // 全选 
    if( checkFlag ) // 全选 
    {
     var inputs = document.all.tags("INPUT");
     for (var i=0; i < inputs.length; i++) // 遍历页面上所有的 input
     {
      if (inputs[i].type == "checkbox" && inputs[i].id != "CheckAll" )
      {
       inputs[i].checked = true;
      }    
     }
     checkFlag = false;
    }
    else                                  // 取消全选
    {
     var inputs = document.all.tags("INPUT");
     for (var i=0; i < inputs.length; i++) // 遍历页面上所有的 input
     {
      if (inputs[i].type == "checkbox" && inputs[i].id != "CheckAll" )
      {
       inputs[i].checked = false;
      }    
     }
     
     checkFlag = true;
    }
   }
function DelRec()
{
 var inputs = document.all.tags("input");
 var selectedLen = 0;
 for( var i=0;i < inputs.length; i ++)
 {
  if(inputs[i].type == "checkbox")
  {
   if( inputs[i].checked )
   {
    if(inputs[i].id != "CheckAll")
    {
     selectedLen ++;
    }
   }
  }
 }
 if( selectedLen == 0 )
 {
  alert("请先选择您要删除的数据!");
 }
 else
 {
  var flag = confirm("您确定要删除所选择的这 " + selectedLen + " 条数据吗?");
  if(flag)
  {
   document.all("bntDelete").click();
  }
 }
}
   //-->

  </script>
 </HEAD>
 <body MS_POSITIONING="GridLayout">
  <form id="Form1" method="post" runat="server">
   <input id="rd" type="hidden" name="rd" runat="server">
   <table cellSpacing="3" cellPadding="2" width="100%" border="0">
    <tr>
     <td align="center" colSpan="3">
      <table height="60" cellSpacing="0" cellPadding="0" width="255" border="0">
       <tr>
        <td background="../../Images/right/title.JPG">
         <div class="title" align="left">
          <div align="center">申请会议</div>
         </div>
        </td>
       </tr>
      </table>
     </td>
     <td vAlign="bottom" noWrap align="right">
      <asp:button id="btnApplyMeeting" runat="server" CssClass="button" Text="申请会议室"></asp:button>
      <asp:button id="btnFirst" onclick="PagerButtonClick" runat="server" CssClass="button" Text="首页"
       CommandArgument="0"></asp:button>
      <asp:button id="btnPerv" onclick="PagerButtonClick" runat="server" CssClass="button" Text="上页"
       CommandArgument="Perv"></asp:button>
      <asp:button id="btnNext" onclick="PagerButtonClick" runat="server" CssClass="button" Text="下页"
       CommandArgument="Next"></asp:button>
      <asp:button id="btnLast" onclick="PagerButtonClick" runat="server" CssClass="button" Text="未页"
       CommandArgument="Last"></asp:button></td>
     </TD>
    </tr>
    <tr>
     <td align="center" colSpan="4">
      <asp:datagrid id="MeetingGrid" runat="server" Width="100%" AutoGenerateColumns="False" CellPadding="3"
       BackColor="White" BorderColor="#92C0E2" AllowPaging="True" PageSize="10" OnPageIndexChanged="MeetingGrid_PageIndexChanged">
       <ItemStyle CssClass="DataGridItem"></ItemStyle>
       <HeaderStyle Wrap="False" HorizontalAlign="Center" CssClass="DataGridHeader"></HeaderStyle>
       <Columns>
        <asp:TemplateColumn HeaderImageUrl="修改" HeaderText="操作">
         <ItemStyle HorizontalAlign="Center"></ItemStyle>
         <HeaderTemplate>
          选择
         </HeaderTemplate>
         <ItemTemplate>
          <INPUT id=RadioName1 type=hidden  value='<%# DataBinder.Eval(Container.DataItem,"id")%>' runat="server">
          <INPUT id=RadioName type=radio value='<%# DataBinder.Eval(Container.DataItem,"id")%>' name=RadioName>
         </ItemTemplate>
        </asp:TemplateColumn>
        <asp:BoundColumn DataField="RoomNo" HeaderText="会议室编号">
         <ItemStyle HorizontalAlign="Center"></ItemStyle>
        </asp:BoundColumn>
        <asp:TemplateColumn HeaderText="会议室名称">
         <ItemStyle Wrap="False"></ItemStyle>
         <ItemTemplate>
          <a href='MeetingDetails.aspx?id=<%#DataBinder.Eval(Container.DataItem,"ID")%>&funId=<%=funId%>' target="_self">
           <%#DataBinder.Eval(Container.DataItem,"RoomName")%>
          </a>
         </ItemTemplate>
        </asp:TemplateColumn>
        <asp:BoundColumn DataField="ContainPerNum" HeaderText="可容纳人数">
         <ItemStyle HorizontalAlign="Center"></ItemStyle>
        </asp:BoundColumn>
        <asp:BoundColumn DataField="Address" HeaderText="会议室地址">
         <ItemStyle HorizontalAlign="Center"></ItemStyle>
        </asp:BoundColumn>
        <asp:TemplateColumn HeaderText="当前状态">
         <ItemStyle Wrap="False" HorizontalAlign="Center"></ItemStyle>
         <ItemTemplate>
          <asp:Label id="lblState" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"CurrentState")%>'/>
         </ItemTemplate>
        </asp:TemplateColumn>
        <asp:BoundColumn DataField="Creater" HeaderText="登记人">
         <ItemStyle HorizontalAlign="Center"></ItemStyle>
        </asp:BoundColumn>
        <asp:BoundColumn DataField="CreateDate" HeaderText="登记日期" DataFormatString="{0:d}">
         <ItemStyle HorizontalAlign="Center"></ItemStyle>
        </asp:BoundColumn>
       </Columns>
       <PagerStyle Visible="False"></PagerStyle>
      </asp:datagrid>&nbsp;</td>
    </tr>
    <tr>
     <td colspan="4" align="right">
      <asp:label id="labTatolRecord" runat="server">Label</asp:label>
      <asp:label id="labTatolPage" runat="server">Label</asp:label>
      <asp:label id="labCurrentPage" runat="server">Label</asp:label></td>
    </tr>
   </table>
  </form>
 </body>
</HTML>