当前位置:编程学习 > C#/ASP.NET >>

哪位大神能帮我解决下这个问题吗

、、、、、、、、、、、、、、、、、、页面的代码、、、、、、、、、、、、、、、、、
<asp:GridView ID="gvrivilege" runat="server" AutoGenerateColumns="False" OnRowDataBound="gvrivilege_RowDataBound"
        EmptyDataText="暂无数据!" DataKeyNames="ID" CellPadding="3"  Width="98%" HorizontalAlign="Center">
        <Columns>
            <asp:TemplateField HeaderText="序号" ItemStyle-HorizontalAlign="Center">
                <ItemTemplate>
                    <asp:Label ID="lblNo" runat="server" Text="<%#Container.DataItemIndex+1 %>"></asp:Label>
                </ItemTemplate>
                <ItemStyle  HorizontalAlign="Center" VerticalAlign="Middle" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="模块列表" ItemStyle-HorizontalAlign="Center">
                <ItemTemplate>
                    <asp:Label ID="lblNbsp" runat="server" Text='<%#Eval("Sort") %>'></asp:Label>
                    <asp:CheckBox ID="chkAll" runat="server" TabIndex="<%#Container.DataItemIndex %>" OnCheckedChanged="chkAll_CheckedChanged" AutoPostBack="True" />
                        <asp:Label ID="lblName" runat="server" Text='<%#Eval("Name") %>'></asp:Label>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
            </asp:TemplateField>
            <asp:TemplateField HeaderText="权限列表" ItemStyle-HorizontalAlign="Center">
                <ItemTemplate>
                    <asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatDirection="Horizontal"></asp:CheckBoxList>
                    <asp:Label ID="Label1" runat="server"></asp:Label>
                </ItemTemplate>
                <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
            </asp:TemplateField>
        </Columns>
          <HeaderStyle BackColor="#CAE8EA" />
    </asp:GridView>
    <asp:Label ID="lblClassCode" runat="server" Visible="False"></asp:Label>
    <asp:Label ID="lblCaption" runat="server" Visible="false"></asp:Label>


、、、、、、、、、、、、、、、、、、实现的效果看图片、、、、、、、



--------------------编程问答-------------------- 你的问题是什么,不会做?其实你用了GridView来绑定,里面每一个项就可以在后台通过FindControl来循环获取控件,进而得到值。这比tree要简单很多。 --------------------编程问答-------------------- 大哥、大姐能不能帮我写段代码出来啊,我是初学者 --------------------编程问答-------------------- 分两步,首先显示如图的效果,其次获取选中的checkbox的值保存到数据库。
你的前台代码已经在上面了。
 <asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatDirection="Horizontal"></asp:CheckBoxList>
这是绑定CheckBoxList的,就是你后面重复的删除...排序之类的。只要在后台给CheckBoxList1绑定数据源(数据源的内容就是删除排序之类的)就可以显示了。
因为CheckBoxList1是在Gridview里面的,要在Gridview绑定的时候FindControl找到每一行的CheckBoxList1,然后执行绑定方法。
有个稍微复杂点的例子,可以参考一下。http://www.cnblogs.com/qishiguilai/archive/2013/02/01/2888886.html --------------------编程问答-------------------- devexpress很容易做出带tree的网格

https://www.devexpress.com/Products/NET/Controls/ASP/Tree_List/
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,