GridView中嵌套GridView

//aspx页面
<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" GridLines="None"
                                    ShowHeader="False" OnRowDataBound="GridView2_RowDataBound">
               <Columns>
                     <asp:TemplateField>
                             <ItemTemplate>
                                 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="true">
                                 </asp:GridView>
                              </ItemTemplate>
                      </asp:TemplateField>
              </Columns>
  </asp:GridView>
//aspx.cs页面
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            GridView Grd = e.Row.Cells[0].FindControl("GridView1") as GridView;
            Grd.DataSource = 数据集;
            Grd.DataBind();
        }      
    }

posted on 2007-03-30 16:08  myer  阅读(2778)  评论(2编辑  收藏  举报

导航