• ASPxGridView 添加勾选列--全选 和 后端获取勾的行ID


    一、HTML 代码

            <table style=" 100%;">
                    <tr>
                        <td>
                            <asp:Button ID="Button1" runat="server" Text="选择账号" OnClick="Button1_Click" />
                        </td>
                        <td>
                            <asp:Button ID="Button2" runat="server" Text="选择菜单" OnClick="Button2_Click" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" KeyFieldName="UsrID" Width="100%">
                                <Settings
                                    GridLines="Both"
                                    ShowGroupPanel="False"
                                    ShowFooter="True"
                                    ShowHeaderFilterButton="true"
                                    ShowGroupFooter="VisibleAlways"
                                    ShowPreview="True"
                                    ShowVerticalScrollBar="True"
                                    VerticalScrollableHeight="500" />
                                <SettingsBehavior AllowDragDrop="true" ColumnResizeMode="Control" AllowFocusedRow="True" AllowSort="true" />
                                <Columns>
                                    <dx:GridViewDataTextColumn Caption="账号" FieldName="UsrID" Name="ColUsrID" VisibleIndex="0" Width="120px">
                                    </dx:GridViewDataTextColumn>
                                    <dx:GridViewDataTextColumn Caption="姓名" FieldName="Name" Name="ColName" VisibleIndex="2" Width="100px">
                                    </dx:GridViewDataTextColumn>
                                    <dx:GridViewDataTextColumn Caption="部门" FieldName="Dep" Name="ColDep" VisibleIndex="3" Width="100px">
                                    </dx:GridViewDataTextColumn>
                                    <dx:GridViewDataTextColumn Caption="是否管理员" FieldName="Rem" Name="ColRem" VisibleIndex="4" Width="100px">
                                    </dx:GridViewDataTextColumn>
                                    <dx:GridViewDataTextColumn Caption="是否停用" FieldName="Sto" Name="ColSto" VisibleIndex="5" Width="100px">
                                    </dx:GridViewDataTextColumn>
                                </Columns>
                            </dx:ASPxGridView>
                        </td>
                        <td>
                            <dx:ASPxGridView ID="ASPxGridView2" runat="server" AutoGenerateColumns="False" KeyFieldName="ItemNO" Width="100%">
                                <Settings
                                    GridLines="Both"
                                    ShowGroupPanel="False"
                                    ShowFooter="True"
                                    ShowHeaderFilterButton="true"
                                    ShowGroupFooter="VisibleAlways"
                                    ShowPreview="True"
                                    ShowVerticalScrollBar="True"
                                    VerticalScrollableHeight="500" />
                                <SettingsBehavior AllowDragDrop="true" ColumnResizeMode="Control" AllowFocusedRow="True" AllowSort="true" />
    
                                <Columns>
                                    <%--;....................................................................;--%> 
                                    <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" Caption="选择" Name="ColChk" Width="36px">
                                        <HeaderTemplate>
                                            <dx:ASPxCheckBox ID="DchkAll" runat="server"  
                                                ClientSideEvents-CheckedChanged="function(s,e){ASPxGridView2.SelectAllRowsOnPage(s.GetChecked());}">
                                            </dx:ASPxCheckBox>
                                        </HeaderTemplate>
                                        <HeaderStyle HorizontalAlign="Center" />
                                    </dx:GridViewCommandColumn> 
                                    <dx:GridViewDataTextColumn Caption="菜单编号" FieldName="ItemNO" Name="ColItemNO" VisibleIndex="3" Width="120px">
                                    </dx:GridViewDataTextColumn>
                                    <dx:GridViewDataTextColumn Caption="菜单名称" FieldName="ItemDesc" Name="CoItemDesc" VisibleIndex="4" Width="200px">
                                    </dx:GridViewDataTextColumn> 
                                </Columns>
    
                            </dx:ASPxGridView>
                        </td>
                    </tr>
                </table>

    二、Cs 后端代码

       /// <summary>
            /// 获取 ItemNO 列的内容
            /// </summary>
            /// <returns></returns>
            protected string GetDelID()
            {
                string delId = "";
                //获取选中的记录Id                   
                List<object> lSelectValues = ASPxGridView2.GetSelectedFieldValues("ItemNO");
                if (lSelectValues.Count==0)
                { return ""; };
                for (int i = 0; i < lSelectValues.Count; i++)
                {
                    delId += lSelectValues[i] + ",";
                }
                delId = delId.Substring(0, delId.LastIndexOf(','));
                return delId;
            }
  • 相关阅读:
    修改python默认版本
    Ansible基础
    day21
    paramiko上传文件到Linux
    参考书籍
    C++解析三
    块设备
    assert用法
    块设备驱动2
    块设备驱动1
  • 原文地址:https://www.cnblogs.com/lanyubaicl/p/7371928.html
Copyright © 2020-2023  润新知