• GridView双层嵌套


    前台代码:

    <div>
            <asp:GridView ID="GridViewOne" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridViewOne_RowDataBound">
                <Columns>
                    <asp:TemplateField>
                        <EditItemTemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("DepartName") %>'></asp:TextBox>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("DepartName") %>'></asp:Label>
                            <br />
                            <asp:GridView ID="GridViewTwo" runat="server">
                            </asp:GridView>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
        </div>
    

    后台代码:

    public partial class WebForm2 : System.Web.UI.Page
        {
            StaffInfoBLL sbll = new StaffInfoBLL();
            DepartmentInfoBLL dbll = new DepartmentInfoBLL();
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack) {
                    InitGridViewOne();
                }
            }
    
            private void InitGridViewOne()
            {
                this.GridViewOne.DataSource = dbll.GetAll();
                this.GridViewOne.DataBind();
            }
    
            protected void GridViewOne_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow) {
                    GridView g = e.Row.FindControl("GridViewTwo") as GridView;
                    DepartmentInfo d = e.Row.DataItem as DepartmentInfo;
                    g.DataSource = sbll.GetByDepartId(d.DepartId);
                    g.DataBind();
                }
            }
        }
    

      

  • 相关阅读:
    POJ 2672 Tarjan + 缩点 + 拓扑思想
    HDU1269迷宫城堡(裸Tarjan有向图求强连通分量个数)
    Tarjan求有向图强连通详解
    Jedis源代码探索
    多线程下使用Jedis
    Jedis分片连接池
    Jedis使用过程中踩过的那些坑
    jedis提纲
    jedis中的一致性hash算法
    字典:dict.c/dict.h
  • 原文地址:https://www.cnblogs.com/liujie1111/p/3648435.html
Copyright © 2020-2023  润新知