维持3级层次结构的最佳方法是什么?

时间:2010-10-22 18:41:09

标签: asp.net

如何使用gridview维护3级层次结构?

1 个答案:

答案 0 :(得分:0)

维护你的意思是什么?我们的应用程序在整个地方都有类似的设置。我们使用嵌入式网格视图没有问题。你需要一些代码来看看它是如何完成的吗?不确定你在找什么..

 <asp:DataGrid ID="dgReportGrid" runat="server" CssClass="grid" Width="100%" OnItemCommand="ExpandDetails"
                                    PagerStyle-Visible="False" AllowPaging="True" font-name="Verdana" AutoGenerateColumns="False"
                                    PageSize="10" OnItemDataBound="dgReportGrid_onItemDataBound">
                                    <HeaderStyle CssClass="gridHeader"></HeaderStyle>
                                    <AlternatingItemStyle CssClass="gridAltRow1"></AlternatingItemStyle>
                                    <ItemStyle CssClass="gridAltRow1"></ItemStyle>
                                    <Columns>
                                        <asp:TemplateColumn HeaderStyle-CssClass="dsLeftBorder">
                                            <ItemStyle Width="10px"></ItemStyle>
                                            <ItemTemplate>
                                                <asp:ImageButton ID="imgBtnExpand" ImageUrl="../images/minus.gif" CommandName="Expand"
                                                    runat="server" ToolTip="show details"></asp:ImageButton>
                                            </ItemTemplate>
                                        </asp:TemplateColumn>
                                        <asp:BoundColumn Visible="False" DataField="a_id" ReadOnly="True" ItemStyle-HorizontalAlign="center">
                                        </asp:BoundColumn>                                      
                                        <asp:BoundColumn DataField="x1" ReadOnly="true" HeaderText="x1"
                                            ItemStyle-HorizontalAlign="center"></asp:BoundColumn>
                                        <asp:BoundColumn DataField="x2" ReadOnly="True" HeaderText="x2"
                                            ItemStyle-HorizontalAlign="center"></asp:BoundColumn>
                                        <asp:BoundColumn DataField="x3" ReadOnly="true" HeaderText="x3"
                                            ItemStyle-HorizontalAlign="center"></asp:BoundColumn>                                      
                                        <asp:TemplateColumn>
                                            <ItemStyle Width="1px"></ItemStyle>
                                            <ItemTemplate>
                                                <asp:PlaceHolder ID="ExpandedContent" runat="server"></TD> </TR>
                                                    <tr>
                                                        <td width="10">
                                                        </td>
                                                        <td colspan="10">
                                                            &nbsp;<br>
                                                            <asp:Label ID="lblNestedGridlbl" runat="server" CssClass="nestedGridLabel" Text='Details'></asp:Label>
                                                            <asp:DataGrid ID="dgDetail" runat="server" Width="100%" font-name="Verdana" AutoGenerateColumns="False"
                                                                OnItemCommand="ExpandDetails" OnItemDataBound="dgDetail_DataBind">
                                                                <HeaderStyle CssClass="nestedGridHeader1"></HeaderStyle>
                                                                <ItemStyle CssClass="gridAltRow1"></ItemStyle>
                                                                <Columns>
                                                                    <asp:TemplateColumn HeaderStyle-CssClass="dsLeftBorder">
                                                                        <ItemStyle Width="10px"></ItemStyle>
                                                                        <ItemTemplate>
                                                                            <asp:ImageButton ID="Imagebutton1" ImageUrl="../images/minus.gif" CommandName="PExpand"
                                                                                runat="server" ToolTip="show details"></asp:ImageButton>
                                                                        </ItemTemplate>
                                                                    </asp:TemplateColumn>
                                                                    <asp:BoundColumn DataField="a1" Visible="False"></asp:BoundColumn>
                                                                    <asp:BoundColumn DataField="a2" Visible="False"></asp:BoundColumn>                                                                   
                                                                    <asp:BoundColumn DataField="a3" HeaderText="Product Family" HeaderStyle-HorizontalAlign="Center"
                                                                        ItemStyle-HorizontalAlign="Center"></asp:BoundColumn>
                                                                    <asp:TemplateColumn>
                                                                        <ItemStyle Width="1px"></ItemStyle>
                                                                        <ItemTemplate>
                                                                            <asp:PlaceHolder ID="ExpandedContent1" runat="server"></TD> </TR>
                                                                                <tr>
                                                                                    <td width="10">
                                                                                    </td>
                                                                                    <td colspan="10">
                                                                                        <asp:DataGrid class="grid" ID="dgProdDetail" runat="server" Width="100%" font-name="Verdana"
                                                                                            AutoGenerateColumns="False" OnItemDataBound="dgProdDetail_DataBind">
                                                                                            <HeaderStyle CssClass="nestedGridHeader2"></HeaderStyle>
                                                                                            <AlternatingItemStyle CssClass="gridAltRow1"></AlternatingItemStyle>
                                                                                            <ItemStyle CssClass="gridRow1"></ItemStyle>
                                                                                            <Columns>                                                                                            
                                                                                                <asp:BoundColumn DataField="c1" HeaderText="c1"></asp:BoundColumn>
                                                                                                <asp:BoundColumn DataField="c2" HeaderText="c2" ItemStyle-HorizontalAlign="Center">
                                                                                                </asp:BoundColumn>
                                                                                                <asp:BoundColumn DataField="c3" HeaderText="c3" ItemStyle-HorizontalAlign="Center">
                                                                                                </asp:BoundColumn>                                                                                             
                                                                                            </Columns>
                                                                                        </asp:DataGrid>