c#大圣之路笔记——c# DataGrid checkbox 操作

Posted 王小二通往大圣之路

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c#大圣之路笔记——c# DataGrid checkbox 操作相关的知识,希望对你有一定的参考价值。

  1 ///html
  2 
  3 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="xOEMStoreNominationForCAM.aspx.cs" EnableEventValidation="false" Inherits="PRCSales_external.Store.xOEMStoreNominationForCAM" %>
  4 
  5 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6 
  7 <html xmlns="http://www.w3.org/1999/xhtml">
  8 <head runat="server">
  9     <title>xOEM Store Nomination for CAM</title>
 10     <link href="../css/main.css" rel="stylesheet" type="text/css" />
 11     <link href="../css/Styles_1.css" rel="stylesheet" type="text/css" />
 12     
 13     <script type="text/javascript" src="../js/jquery-1.8.2.js"></script>
 14     <script type="text/javascript" src="../js/LocationFilterQuarter.js"></script>
 15 
 16     <script type="text/javascript">
 17 
 18 
 19             function CheckAll(chkObject) {
 20                 var checkArray = document.getElementsByTagName("input");
 21                 for (j = 0; j < checkArray.length; j++) {
 22                     if (checkArray[j].type == "checkbox" & checkArray[j] != chkObject ) {
 23                         if (chkObject.checked != checkArray[j].checked)
 24                             checkArray[j].checked = chkObject.checked;
 25                     }
 26                 }
 27             }
 28 
 29          
 30 
 31 
 32             function ShowWaiting() {
 33                 document.getElementById(doing).style.visibility = visible;
 34             }
 35             function CloseWaiting() {
 36                 document.getElementById(doing).style.visibility = hidden;
 37             }
 38             function MyOnload() {
 39                 document.getElementById(doing).style.visibility = hidden;
 40             }
 41 
 42             if (window.onload == null) {
 43                 window.onload = MyOnload;
 44             }
 45 
 46     </script>
 47 
 48 
 49     <style type="text/css">
 50             #btnMark ,#btnUnmark
 51             {
 52                 margin-left:5px;
 53             }
 54     
 55     </style>
 56 
 57 
 58 </head>
 59 <body>
 60     <form id="form1" runat="server"> 
 61     <table width="100%" id="Table1">
 62         <tr ><td style="height:30px; "><b>xOEM Store Nomination for CAM</b></td></tr>
 63         <tr>
 64          <tr style="HEIGHT: 1px; BACKGROUND-COLOR: #3366ff">
 65                     <td colSpan="4"><FONT style="BACKGROUND-COLOR: #ffffff" face="宋体"></FONT><FONT face="宋体"></FONT></td>
 66                 </tr>
 67         <tr>
 68                 <td class="fieldtitle" width="30%">Quarter:</td>
 69                 <td class="fieldtitle" width="20%"><asp:dropdownlist id="ddlQuarter" runat="server"  AutoPostBack="true"
 70                         onselectedindexchanged="ddlQuarter_SelectedIndexChanged"  onchange="initData(‘region‘)"></asp:dropdownlist></td>
 71                 <td class="fieldtitle" width="20%">
 72                     Region/Grid/City:
 73                 </td>
 74                 <td class="fieldtitle" colspan="3" width="30%">
 75                     <asp:DropDownList ID="ddlRegion" runat="server" CssClass="fieldList" onchange="initData(‘subregion‘)">
 76                     </asp:DropDownList>
 77                     <asp:DropDownList ID="ddlSubRegion" runat="server" CssClass="fieldList" style="display:none;" onchange="initData(‘grid‘)">
 78                     </asp:DropDownList>
 79                     <asp:DropDownList ID="ddlGrid" runat="server" CssClass="fieldList"  onchange="initData(‘pref‘)">
 80                     </asp:DropDownList>
 81                     <asp:DropDownList ID="ddlPref" runat="server" CssClass="fieldList" style="display:none;"  onchange="initData(‘city‘)">
 82                     </asp:DropDownList>
 83                     <asp:DropDownList ID="ddlCity" runat="server" CssClass="fieldList"  onchange="initData(‘county‘)">
 84                     </asp:DropDownList>
 85                     <asp:DropDownList ID="ddlCounty" runat="server" CssClass="fieldList" style="display:none;" onchange="initData(‘town‘)">
 86                     </asp:DropDownList>
 87                     <asp:DropDownList ID="ddlTown" runat="server" CssClass="fieldList" style="display:none;" onchange="initData(‘village‘)">
 88                     </asp:DropDownList>
 89                     <asp:DropDownList ID="ddlVillage" runat="server" CssClass="fieldList" style="display:none;" onchange="initData(‘village1‘)">
 90                     </asp:DropDownList>
 91                         
 92                     <asp:TextBox ID="txtWWID" runat="server" Style="display: none"></asp:TextBox>
 93                     <asp:TextBox ID="txtQuarter" runat="server" Style="display: none"></asp:TextBox>
 94                     <asp:TextBox ID="txtRegion" runat="server" Style="display: none"></asp:TextBox>
 95                     <asp:TextBox ID="txtSubRegion" runat="server" Style="display: none"></asp:TextBox>
 96                     <asp:TextBox ID="txtGrid" runat="server" Style="display: none"></asp:TextBox>
 97                     <asp:TextBox ID="txtPref" runat="server" Style="display: none"></asp:TextBox>
 98                     <asp:TextBox ID="txtCity" runat="server" Style="display: none"></asp:TextBox>
 99                     <asp:TextBox ID="txtCounty" runat="server" Style="display: none"></asp:TextBox>
100                     <asp:TextBox ID="txtTown" runat="server" Style="display: none"></asp:TextBox>
101                     <asp:TextBox ID="txtVillage" runat="server" Style="display: none"></asp:TextBox>
102                 </td>
103 
104         </tr>
105         <tr>
106             <td class="fieldtitle" width="30%" >Store Name:</td>
107             <td class="fieldtitle" width="20%" colspan="1"><asp:TextBox ID="txtStorNm" runat="server"></asp:TextBox></td>
108             <td class="fieldtitle" width="20%" >Store ID:</td>
109             <td class="fieldtitle" width="30%"><asp:TextBox ID="txtStorID" runat="server"></asp:TextBox></td>
110         </tr>
111        <%-- <tr>
112             <td  class="fieldtitle" width="20%" colspan=""><asp:CheckBox ID="chkStore"  runat="server" CssClass="fieldtitle" Text="Show Unassigned Store Only"/></td>
113         </tr>--%>
114         <tr style="HEIGHT: 1px; BACKGROUND-COLOR: #3366ff">
115                     <td colSpan="4"><FONT style="BACKGROUND-COLOR: #ffffff" face="宋体"></FONT><FONT face="宋体"></FONT></td>
116                 </tr>
117         <tr>
118             <td class="fieldtitle" width="30%" colspan="1">Store list <asp:Label ID="lblCount" runat="server" CssClass="fieldList"></asp:Label>
119               <%-- <asp:Label ID="lblMessage" runat="server" CssClass="fieldList" ForeColor="Red" Text="季度店面标记"></asp:Label>  --%>
120                     <asp:Label ID="lblLeftTime" CssClass="fieldList" runat="server" ForeColor="Red"></asp:Label>  
121             </td>
122              
123             <td align="right" colspan="3" width="70%">
124             <asp:Button ID="btnSearch" runat="server" Text="Search"   CssClass="fieldButton" onclick="btnSearch_Click"  Width="80px"/> 
125             <asp:Button ID="btnMark" runat="server" Text="Mark"   CssClass="fieldButton" onclick="btnMark_Click" Width="80px" />
126             <asp:Button ID="btnUnmark" runat="server" Text="Unmark" CssClass="fieldButton"   onclick="btnUnmark_Click" Width="80px" />
127             </td>
128         </tr>
129         <tr>
130             <td colspan="4">
131                 <asp:DataGrid ID="GridMain" runat="server" Width="100%" 
132                     AutoGenerateColumns="false" PageSize="20" AllowPaging="true" 
133                      onselectedindexchanged="GridMain_SelectedIndexChanged"  onpageindexchanged="GridMain_PageIndexChanged">
134                 <AlternatingItemStyle CssClass="datagridAlternating" />
135                 <HeaderStyle CssClass="tableHead" />
136                 <Columns>
137                     <asp:TemplateColumn>
138                    <HeaderStyle Width="20px"></HeaderStyle>
139                      <HeaderTemplate><asp:CheckBox ID ="checkAll" runat="server" onclick="CheckAll(this);" /></HeaderTemplate>
140                      <ItemTemplate><asp:CheckBox ID="chkSelected" runat="server"  /></ItemTemplate>
141                     </asp:TemplateColumn>
142                     <asp:BoundColumn DataField="stor_rgn_nm" HeaderText="Store Region">
143                                     <ItemStyle HorizontalAlign="Center" Width="4%"></ItemStyle>
144                     </asp:BoundColumn>
145                   <asp:BoundColumn DataField="stor_grid_cd" HeaderText="Store Grid">
146                                     <ItemStyle HorizontalAlign="Center" Width="3%"></ItemStyle>
147                     </asp:BoundColumn>
148                     <asp:BoundColumn DataField="stor_city_std_loc_nm" HeaderText="Store City">
149                                     <ItemStyle HorizontalAlign="Center" Width="4%"></ItemStyle>
150                     </asp:BoundColumn>
151                      <asp:BoundColumn DataField="stor_id" HeaderText="Store ID">
152                                     <ItemStyle HorizontalAlign="Center" Width="3%"></ItemStyle>
153                     </asp:BoundColumn>
154                      <asp:BoundColumn DataField="stor_nm" HeaderText="Store Name">
155                                     <ItemStyle HorizontalAlign="Center" Width="8%"></ItemStyle>
156                     </asp:BoundColumn>
157                     <asp:BoundColumn DataField="stor_addr" HeaderText="Store Addr">
158                                     <ItemStyle HorizontalAlign="Center" Width="8%"></ItemStyle>
159                     </asp:BoundColumn>
160                      <asp:BoundColumn DataField="brnd_nm" HeaderText="Store Brand">
161                                     <ItemStyle HorizontalAlign="Center" Width="4%"></ItemStyle>
162                     </asp:BoundColumn>
163                      <asp:BoundColumn DataField="xoem_store_tier" HeaderText="Store Tier">
164                                     <ItemStyle HorizontalAlign="Center" Width="3%"></ItemStyle>
165                     </asp:BoundColumn>
166                      <asp:BoundColumn DataField="remark" HeaderText="Store Bis Type">
167                                     <ItemStyle HorizontalAlign="Center" Width="4%"></ItemStyle>
168                     </asp:BoundColumn>
169                      <asp:BoundColumn DataField="oem_stor_id" HeaderText="OEM Store ID">
170                                     <ItemStyle HorizontalAlign="Center" Width="4%"></ItemStyle>
171                     </asp:BoundColumn>
172                      <asp:BoundColumn DataField="rep_nm" HeaderText="Store Manager">
173                                     <ItemStyle HorizontalAlign="Center" Width="3%"></ItemStyle>
174                     </asp:BoundColumn>
175                        <asp:BoundColumn DataField="slsprs_nm" HeaderText="SR Owner">

以上是关于c#大圣之路笔记——c# DataGrid checkbox 操作的主要内容,如果未能解决你的问题,请参考以下文章

c#大圣之路笔记——TFS解决离职人员文件签出遗留签入问题

SQL大圣之路笔记——SQL学习笔记

SQL大圣之路笔记——SQL 创建索引 index

SQL大圣之路笔记——SQL 获取excel中的数据

C#入门详解笔记

C# datagrid 隐藏列(编号)