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();
}
}
<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();
}
}