模板列传值到子窗体中,子窗体中多选gridview中checkbox保存数据多项到数据库中

 1 <html xmlns="http://www.w3.org/1999/xhtml">
 2 <head runat="server">
 3     <title></title>
 4 
 5     <script src="../../../Scripts/jquery.js" type="text/javascript" language="javascript"></script>
 6 
 7     <script src="../../../Scripts/jquery.foe.common.js" type="text/javascript"></script>
 8 
 9     <script src="../../../Scripts/jquery.foe.utils.js" type="text/javascript"></script>
10 
11     <script type="text/javascript" language="javascript">
12         function openpage(GroupID) {
13             OpenPage('Sys_UserGroupPermissionEmployeeInfo.aspx?GroupID=' + GroupID + '', '人员管理', '800','600');
14         }
15         function openwin(groupID) {
16             OpenPage('Sys_UserGroupPermissionInfo.aspx?GroupID=' + groupID + '', '权限管理', '800', '600');
17         }
18      </script>
19 
20 </head>
21 <body>
22 <form id="form1" runat="server">
23     <telerik:RadScriptManager ID="scriptManager" runat="server">
24     </telerik:RadScriptManager>
25     <table class="TableStyle">
26         <tr>
27             <th>
28                 用户组名称:
29             </th>
30             <td>
31                 <asp:TextBox ID="txtGroupName" runat="server" CssClass="Input">
32                 </asp:TextBox>
33             </td>
34             <th>
35                 用户组编码:
36             </th>
37             <td>
38                 <asp:TextBox ID="txtGroupCode" runat="server" CssClass="Input"></asp:TextBox>
39             </td>
40         </tr>
41     </table>
42     <telerik:RadToolBar ID="toolBar" runat="server" Width="100%" OnButtonClick="toolBar_ButtonClick"
43         Height="22px">
44         <Items>
45             <telerik:RadToolBarButton Text="查询" ImageUrl="../../../Common/images/ToolBarIcons/search.png">
46             </telerik:RadToolBarButton>
47         </Items>
48     </telerik:RadToolBar>
49     <telerik:RadGrid AlternatingItemStyle-CssClass="AlterLine" ID="dgGroups" runat="server"
50         AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" PagerStyle-AlwaysVisible="true"
51         AllowCustomPaging="true" PagerStyle-Mode="NextPrevAndNumeric" OnNeedDataSource="dgGroups_NeedDataSource"
52         PageSize="10">
53         <MasterTableView DataKeyNames="GroupID" ClientDataKeyNames="GroupID">
54             <Columns>
55                 <telerik:GridBoundColumn HeaderText="用户组名称" DataField="GroupName">
56                     <HeaderStyle Width="200px" />
57                 </telerik:GridBoundColumn>
58                 <telerik:GridBoundColumn HeaderText="用户组编码" DataField="GroupCode">
59                     <HeaderStyle Width="200px" />
60                 </telerik:GridBoundColumn>
61                 <telerik:GridTemplateColumn>
62                     <HeaderTemplate>
63                         人员
64                     </HeaderTemplate>
65                     <ItemTemplate>
66                         <a href="#" onclick='openpage(<%#Eval("GroupID") %>)'>点击查看</a>
67                     </ItemTemplate>
68                 </telerik:GridTemplateColumn>
69                 <telerik:GridTemplateColumn>
70                     <HeaderTemplate>
71                         权限
72                     </HeaderTemplate>
73                     <ItemTemplate>
74                      <a href="#" onclick='openwin(<%#Eval("GroupID") %>)'>点击查看</a>
75                     </ItemTemplate>
76                 </telerik:GridTemplateColumn>
77             </Columns>
78         </MasterTableView>
79     
80     </telerik:RadGrid>
81     <asp:HiddenField ID="hfGroupID" runat="server" />
82     </form>
83 </body>
84 </html>
 1  private Org_UserGroupBLL bll = new Org_UserGroupBLL();
 2 
 3         protected void Page_Load(object sender, EventArgs e)
 4         {
 5             if (!IsPostBack)
 6             {
 7                 ViewState["groupName"] = string.Empty;
 8                 ViewState["groupCode"] = string.Empty;
 9             }
10 
11             SetPager(this.dgGroups);
12         }
13 
14         protected void toolBar_ButtonClick(object sender, RadToolBarEventArgs e)
15         {
16             this.dgGroups.CurrentPageIndex = 0;
17             ViewState["groupName"] = this.txtGroupName.Text;
18             ViewState["groupCode"] = this.txtGroupCode.Text;
19             this.dgGroups.Rebind();
20         }
21 
22         protected void dgGroups_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
23         {
24             int count = 0;
25             this.dgGroups.DataSource = bll.GetGroups(this.dgGroups.CurrentPageIndex * this.dgGroups.PageSize, this.dgGroups.PageSize, ref count, (string)ViewState["groupName"], (string)ViewState["groupCode"]);
26             this.dgGroups.VirtualItemCount = count;
27             this.hfGroupID.Value = string.Empty;
28         }
后台代码
 1 <html xmlns="http://www.w3.org/1999/xhtml">
 2 <head runat="server">
 3     <title>无标题页</title>
 4 
 5     <script src="../../../Scripts/jquery.js" type="text/javascript"></script>
 6 
 7 </head>
 8 <body>
 9     <form id="form1" runat="server">
10     <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
11     </telerik:RadScriptManager>
12     <telerik:RadGrid AlternatingItemStyle-CssClass="AlterLine" ID="dgRoleUsers" runat="server"
13         AutoGenerateColumns="false" PageSize="20" OnNeedDataSource="dgRoleUsers_NeedDataSource"
14         AllowPaging="true" AllowMultiRowSelection="true" AllowCustomPaging="true" PagerStyle-AlwaysVisible="true"
15         PagerStyle-Mode="NextPrevAndNumeric" Width="100%">
16         <MasterTableView ClientDataKeyNames="RelationID" DataKeyNames="RelationID">
17             <Columns>
18                 <telerik:GridTemplateColumn HeaderText="部门" ItemStyle-Width="450px">
19                     <ItemTemplate>
20                         <%# GetDeparementFullName(Convert.ToInt32(Eval("UserID"))) %>
21                     </ItemTemplate>
22                 </telerik:GridTemplateColumn>
23                 <telerik:GridBoundColumn HeaderText="姓名" DataField="UserName">
24                 </telerik:GridBoundColumn>
25             </Columns>
26         </MasterTableView>
27         <ClientSettings>
28             <Selecting AllowRowSelect="true" />
29         </ClientSettings>
30     </telerik:RadGrid>
31     <asp:HiddenField ID="hfRoleID" runat="server" />
32     </form>
33 </body>
34 </html>
列表-前台页面
 1  private Org_Relation_UserToGroupBLL bll = new Org_Relation_UserToGroupBLL();
 2 
 3         protected void Page_Load(object sender, EventArgs e)
 4         {
 5             if (!IsPostBack)
 6             {
 7                 this.hfRoleID.Value = Convert.ToInt32(Request.QueryString["GroupID"]).ToString();
 8             }
 9 
10             int UserDepID = 1;
11             if (CurrentUser.Project != null)
12             {
13                 UserDepID = CurrentUser.Project.DepID;
14             }
15             else if (CurrentUser.SubCompany != null)
16             {
17                 UserDepID = CurrentUser.SubCompany.DepID;
18             }
19             else
20             {
21                 UserDepID = 1;
22             }
23 
24             SetPager(this.dgRoleUsers);
25         }
26         protected void dgRoleUsers_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
27         {
28             Foe.Common.HelperClass.Pagination pa = new Foe.Common.HelperClass.Pagination();
29             pa.PageSize = this.dgRoleUsers.PageSize;
30             pa.PageIndex = dgRoleUsers.CurrentPageIndex + 1;
31 
32             Foe.Model.Organization.Org_Relation_UserToGroup model = new Foe.Model.Organization.Org_Relation_UserToGroup();
33             model.GroupID = Convert.ToInt32(this.hfRoleID.Value);
34 
35             int UserDepID = 0;
36 
37             if (CurrentUser.Project != null)
38             {
39                 UserDepID = CurrentUser.Project.DepID;
40             }
41             else if (CurrentUser.SubCompany != null)
42             {
43                 UserDepID = CurrentUser.SubCompany.DepID;
44             }
45             this.dgRoleUsers.DataSource = bll.GetListByPage(model, pa, UserDepID);
46             this.dgRoleUsers.VirtualItemCount = pa.TotalRecord;
47         }
48 
49         /// <summary>
50         /// 初始化用户部门全路径
51         /// </summary>
52         public string GetDeparementFullName(int userID)
53         {
54             Foe.BLL.Organization.Org Organizationll = new Foe.BLL.Organization.Org();
55 
56             return Organizationll.GetFullPathByEmpID(userID);
57 
58         }
列表-后台代码
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>

    <script src="../../../Scripts/jquery.js" type="text/javascript"></script>

    <script src="../../../Scripts/jquery.foe.common.js" type="text/javascript"></script>

    <script src="../../../Scripts/jquery.foe.utils.js" type="text/javascript"></script>

    <script type="text/javascript" language="javascript">
        $(document).ready(function() {
            $('#btnSave').click(function() {
                var GroupId = $("#hidGroupId").val();
                var check = $("input[type='checkbox']");
                check.each(function() {
                    if ($(this).is(':checked')) {
                        var flowid = $(this).next('input:hidden[id*=hidID]').val();
                        if (flowid != "" && flowid != "undefined") {
                            SaveFlowInfo(GroupId, flowid);
                        }
                        else
                        { return false; }
                    }
                });
                alert('保存成功');
                opener.location.reload();
                window.close();
            });
        });

        function SaveFlowInfo(GroupId, flowid) {
            $.ajax({
                type: "post",
                url: "Sys_UserGroupPermissionSaveFlowInfo.ashx?GroupId=" + escape(GroupId) + "&&FixedFlowID=" + escape(flowid),
                dataType: "json",
                contentType: "application/x-www-form-urlencoded; charset=utf-8",
                success: function(data) {
                    if (data != null) {
                        return true;

                    }
                    else {
                        return false;
                    }
                },

                error: function(XMLHttpRequest, textStatus, errorThrown) { return false; }

            });


        }
        
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <div>
        <telerik:RadGrid AlternatingItemStyle-CssClass="AlterLine" ID="dgManage" runat="server"
            AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true" PagerStyle-AlwaysVisible="true"
            AllowMultiRowSelection="true" AllowCustomPaging="true" PagerStyle-Mode="NextPrevAndNumeric"
            OnNeedDataSource="dgManage_NeedDataSource" PageSize="10">
            <MasterTableView DataKeyNames="FixedFlowID,FixedFlowTypeFullName" ClientDataKeyNames="FixedFlowID,FixedFlowTypeFullName">
                <Columns>
                    <%--<telerik:GridClientSelectColumn UniqueName="FixedFlowID" />
                   --%>
                    <telerik:GridTemplateColumn HeaderText="选择" ItemStyle-Width="50px" HeaderStyle-Width="50px">
                        <ItemTemplate>
                            <input type="checkbox" id="ckhItem" runat="server" />
                            <asp:HiddenField ID="hidID" runat="server" Value='<%#Eval("FixedFlowID") %>' />
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" Width="50px" />
                    </telerik:GridTemplateColumn>
                    <telerik:GridBoundColumn HeaderText="编号" DataField="FixedFlowID" Visible="false"
                        HeaderStyle-Width="80px" ItemStyle-Width="80px">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="流程名称" DataField="FixdeFlowName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="类别" DataField="FixedFlowTypeFullName">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
            <ClientSettings>
                <Selecting AllowRowSelect="true" />
                <Resizing AllowColumnResize="true" ResizeGridOnColumnResize="true" />
            </ClientSettings>
            <PagerStyle Mode="NextPrevAndNumeric" />
        </telerik:RadGrid>
    </div>
    <div style="margin: 5px auto;  100%; text-align: center">
        <input type="button" id="btnSave" value="保存" class="btn" />&nbsp;<input type="button"
            value="关闭" class="btn" onclick="window.close()" />
    </div>
    <asp:HiddenField ID="hidFixedFlowID" runat="server" />
    <asp:HiddenField ID="hidGroupId" runat="server" />
    </form>
</body>
</html>
新增多项前台页面代码
 1 Foe._2B2C.Model.ModelTempTableFlow mode = new Foe._2B2C.Model.ModelTempTableFlow();
 2 
 3       
 4         protected void Page_Load(object sender, EventArgs e)
 5         {
 6             this.hidGroupId.Value = Request.QueryString["GroupID"];
 7             if (!IsPostBack)
 8             {
 9                 BindDataSource();
10             }
11             SetPager(this.dgManage);
12         }
13 
14         protected void dgManage_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
15         {
16             BindDataSource();
17         }
18        
19         protected void BindDataSource()
20         {
21             var pi = new Foe.Common.HelperClass.Pagination()
22             {
23                 PageIndex = this.dgManage.CurrentPageIndex + 1
24             };
25          
26             this.dgManage.DataSource = new Foe._2B2C.BLL.BLLTempTableFlow().GetList(mode, pi);
27             this.dgManage.VirtualItemCount = pi.TotalRecord;
28         }
新增后台代码


原文地址:https://www.cnblogs.com/652769324qq/p/4324005.html