1,绑定数据前先动态添加列,见方法CreateGridColumn(只在第一次加载动态添加);

2,gvlist_RowDataBound为对应列添加控件;

 

前台代码:

 1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="modifysetLeaveconfig2.aspx.cs"
 2     Inherits="web.system.modifysetLeaveconfig2" %>
 3 
 4 <%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
 5 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 6 <html xmlns="http://www.w3.org/1999/xhtml">
 7 <head id="Head1" runat="server">
 8     <title></title>
 9     <link href="/css/default.css" rel="stylesheet" type="text/css" />
10     <link href="/css/jquery.ui.all.css" rel="stylesheet" type="text/css" />
11     <script type="text/javascript" src="/js/jquery-1.9.1.js"></script>
12     <script type="text/javascript" src="/js/jquery.ui.core.js"></script>
13     <script type="text/javascript" src="/js/jquery.ui.widget.js"></script>
14     <script type="text/javascript" src="/js/jquery.ui.mouse.js"></script>
15     <script type="text/javascript" src="/js/jquery.ui.draggable.js"></script>
16     <script type="text/javascript" src="/js/jquery.ui.position.js"></script>
17     <script type="text/javascript" src="/js/jquery.ui.resizable.js"></script>
18     <script type="text/javascript" src="/js/jquery.ui.button.js"></script>
19     <script type="text/javascript" src="/js/jquery.ui.dialog.js"></script>
20     <script type="text/javascript" src="/js/jquery.ui.datepicker.js"></script>
21     <script type="text/javascript" src="/js/common.js"></script>
22     <script type="text/javascript" src="/js/jquery.validate.js"></script>
23 </head>
24 <body>
25     <form id="form1" runat="server">
26     <asp:HiddenField runat="server" ID="hfscmcid" />
27     <asp:HiddenField runat="server" ID="hfplatform" />
28     <div class="container">
29         <div class="content">
30             <div class="cPanel">
31                 <div class="detailPanel">
32                     <asp:GridView ID="gvlist" GridLines="None" runat="server" CellSpacing="0" BorderWidth="0"
33                         CellPadding="0" class="oderListTbl" AutoGenerateColumns="False" EmptyDataText="没有找到数据"
34                         OnRowCommand="gvlist_RowCommand" OnRowDataBound="gvlist_RowDataBound">
35                         <Columns>
36                             <asp:TemplateField ItemStyle-Width="60px">
37                                 <HeaderTemplate>
38                                     <asp:CheckBox ID="cbAll" runat="server" Text="" onclick="javascript:SelectAll(this)" />
39                                     <br />
40                                     <asp:LinkButton ID="lbtall" runat="server" OnClientClick="javascript:return confirm('您确定要批量更新该数据吗?');"
41                                         CommandName="updateall" CommandArgument='<%# Eval("scmcid")+","+Eval("policytype") %>'>批量更新</asp:LinkButton>
42                                 </HeaderTemplate>
43                                 <ItemTemplate>
44                                     <asp:CheckBox ID="cbItem" runat="server" />
45                                     <asp:HiddenField ID="hfpolicytype" runat="server" Value='<%# Eval("policytype")%>' />
46                                 </ItemTemplate>
47                             </asp:TemplateField>
48                             <asp:TemplateField HeaderText="政策类型" ItemStyle-Width="50px">
49                                 <ItemTemplate>
50                                     <%# Eval("name")%>
51                                 </ItemTemplate>
52                             </asp:TemplateField>
53                             <asp:TemplateField HeaderText="状态" ItemStyle-Width="50px">
54                                 <ItemTemplate>
55                                     <asp:LinkButton ID="lbtModify" runat="server" CommandName="udtallstate" CommandArgument='<%# Eval("scmcid")+","+Eval("policytype") %>'
56                                         ToolTip="点击更改状态" Text="启/禁用"></asp:LinkButton>
57                                 </ItemTemplate>
58                             </asp:TemplateField>
59                         </Columns>
60                     </asp:GridView>
61                     <div class="pager">
62                         <webdiyer:AspNetPager ID="pager" CssClass="paginator" CurrentPageButtonClass="cpb"
63                             runat="server" AlwaysShow="True" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页"
64                             PageSize="1000000" PrevPageText="上一页" ShowCustomInfoSection="Left" ShowInputBox="Never"
65                             OnPageChanging="pager_PageChanging" CustomInfoTextAlign="Left" LayoutType="Table"
66                             CustomInfoHTML="总条数:%RecordCount%  当前页数 %CurrentPageIndex% of %PageCount%">
67                         </webdiyer:AspNetPager>
68                     </div>
69                 </div>
70             </div>
71         </div>
72         <div class="clr">
73         </div>
74     </div>
75     </form>
76     <script type="text/javascript">
77 
78         $(function () {
79             $("#gvlist tr:odd").addClass("highLight");
80         });
81         function SelectAll(aControl) {
82             var tempControl = aControl;
83             var isChecked = tempControl.checked;
84 
85             elem = tempControl.form.elements;
86             for (i = 0; i < elem.length; i++)
87                 if (elem[i].type == "checkbox" && elem[i].id != tempControl.id) {
88                     if (elem[i].checked != isChecked)
89                         elem[i].click();
90                 }
91         }
92     </script>
93 </body>
94 </html>
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
  • 2022-12-23
猜你喜欢
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
  • 2022-12-23
相关资源
相似解决方案