我有点新手,我需要一个父/子/孙 (3d) 可折叠表或 gridview 或手风琴......我不确定使用哪个以及如何实现。任何帮助将不胜感激!
我试过手风琴和嵌套的网格视图。数据正在正确加载和绑定,但无法展开/折叠工作。
所以我决定使用嵌套的网格视图,并使用一些 jquery 来展开折叠。所以我现在的问题是访问最深表中的行。基本上选择最低级别(汽车)中的行并按下按钮以对它们采取行动。在后面的 vb 代码中,我还没有弄清楚如何访问除顶部数据网格之外的任何内容。不确定这里的格式如何,但这是 aspx:
<asp:GridView ID="gvYards" runat="server" AutoGenerateColumns="false" CssClass="GridView"
DataKeyNames="YardID" OnRowDataBound="OnRowYardDataBound" HorizontalAlign="Center" Width="30%">
<RowStyle CssClass="Row" />
<AlternatingRowStyle CssClass="AltRow" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<img alt="" style="cursor: pointer" src="images/plus.jpg" />
<asp:Panel id="pnlTracks" runat="server" Style="display: none">
<asp:GridView ID="gvTracks" runat="server" AutoGenerateColumns="false" CssClass="ChildGrid"
DataKeyNames="TrackID" OnRowDataBound="OnRowTrackDataBound">
<RowStyle CssClass="Row" />
<AlternatingRowStyle CssClass="AltRow" />
<Columns>
<asp:TemplateField>
<ItemTemplate>
<img alt="" style="cursor: pointer" src="images/plus.jpg" />
<asp:Panel ID="pnlCars" runat="server" Style="display: none">
<asp:GridView ID="gvCars" runat="server" MultiSelect="True" SelectionMode="FullRowSelect" AutoGenerateColumns="false"
CssClass="ChildGrid" DataKeyNames="CarID">
<RowStyle CssClass="Row" />
<AlternatingRowStyle CssClass="AltRow" />
<Columns>
<asp:BoundField ItemStyle-Width="50px" DataField="CarID" HeaderText="CarID" Visible="false" />
<asp:BoundField ItemStyle-Width="550px" DataField="CustomerName" HeaderText="Group/Customer" />
<asp:BoundField ItemStyle-Width="50px" DataField="CurrentPosition" HeaderText="Position" />
<asp:BoundField ItemStyle-Width="100px" DataField="Mark" HeaderText="Mark" />
<asp:BoundField ItemStyle-Width="100px" DataField="Number" HeaderText="Number" />
<asp:BoundField ItemStyle-Width="350px" DataField="TypeName" HeaderText="Type" />
<asp:BoundField ItemStyle-Width="350px" DataField="StatusName" HeaderText="Status" />
</Columns>
</asp:GridView>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField ItemStyle-Width="50px" DataField="TrackID" HeaderText="Track ID" Visible="false" />
<asp:BoundField ItemStyle-Width="250px" DataField="TrackName" HeaderText="Track" />
<asp:BoundField ItemStyle-Width="100px" DataField="LengthInFeet" HeaderText="Length" />
<asp:BoundField ItemStyle-Width="100px" DataField="AvailableFeet" DataFormatString="{0:0}" HeaderText="Available" />
</Columns>
</asp:GridView>
</asp:Panel>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField ItemStyle-Width="450px" DataField="YardName" HeaderText="Yard Name" />
</Columns>
</asp:GridView>
</div>
这是一些测试内容的代码:
Private Sub MoveButton_Click(ByVal sender As Object, ByVal e As EventArgs) 处理 MoveButton.Click
Dim p0 As GridView = CType(Me.gvYards, GridView) 'this works, can access yard rows
Dim ch0 As GridView = CType(p0.Controls(0).FindControl("gvTracks"), GridView) 'gives nothing
Dim p1 As GridView = CType(p0.FindControl("gvTracks"), GridView)'gives nothing
Dim ch1 As GridView = CType(p1.Controls(0).FindControl("gvCars"), GridView) 'gives object not set to an instance, never goes farther
Dim p2 As GridView = CType(p1.FindControl("gvCars"), GridView)
For Each row As GridViewRow In p2.Rows
If row.RowState = DataControlRowState.Selected Then
Dim value1 As Object = row.Cells.ToString() 'just do something to test
End If
Next
Exit Sub