我正在尝试制作嵌套列表视图。但内部列表视图没有显示。外部正在显示。
我有外部列表视图和内部列表视图。每个都有自己的sqldatasource。问题是我无法将“subcat”获取到内部列表视图,这就是为什么第二个列表视图不包含任何数据。
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="subcat">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="itemPlaceholder" />
</LayoutTemplate>
<ItemTemplate>
<div class="wrap normal">
<div class="bubble round-tl mb-5 cerulean bubble-border-blue path-container wow fadeIn"
role="complementary">
<div class="inner">
<h3>
<asp:Label ID="subcatLabel" runat="server" Text='<%# Eval("subcat") %>' ></asp:Label>
</h3>
<ol class="path-list hidden-list" aria-hidden="true">
<asp:ListView ID="myListView" runat="server" DataSourceID="data" ItemPlaceholderID="itemPlaceholder1">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="itemPlaceholder1" />
</LayoutTemplate>
<ItemTemplate>
<div style="float: left;">
<li class="path-item wow fadeIn" data-wow-delay="0s"><a
class="button round-tiny thin cerulean block"
href="/main_content?con=What-is-mental-illness?" style="width:230px;"><span
class="table"><span class="cell">
<asp:Label ID="b_nameLabel" runat="server" Text='<%# Eval("b_name").ToString.Replace("-", " ") %>' />
</span></span></a></li>
<%--<li class="path-spacer path-spacer-mobile wow fadeIn" data-wow-delay="0s"></li>--%>
</div>
</ItemTemplate>
</asp:ListView>
<asp:SqlDataSource runat="server" ID="data" ConnectionString="<%$ ConnectionStrings:aarogyamindConnectionString %>" SelectCommand="SELECT [b_name] FROM [blog] WHERE ([b_sub_cat] = @b_sub_cat)">
<SelectParameters>
<asp:ControlParameter ControlID="subcat" Name="b_sub_cat" PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</ol>
</div>
</div>
</div>
</ItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:aarogyamindConnectionString %>" SelectCommand="SELECT [subcat] FROM [categories] WHERE ([category] = @category)">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="New-cat" Name="category" QueryStringField="category" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
我尝试了一切,例如更改属性名称和控制器名称。
是的,已经解决了。
这是我成功执行的代码。
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="subcat">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="itemPlaceholder" />
</LayoutTemplate>
<ItemTemplate>
<div class="wrap normal">
<div class="bubble round-tl mb-5 cerulean bubble-border-blue path-container wow fadeIn"
role="complementary">
<div class="inner">
<h3>
<asp:Label ID="subcatLabel" runat="server" Text='<%# Eval("subcat") %>' ></asp:Label>
</h3>
<ol class="path-list hidden-list" aria-hidden="true">
<asp:ListView ID="myListView" runat="server" DataSourceID="data" ItemPlaceholderID="itemPlaceholder1">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="itemPlaceholder1" />
</LayoutTemplate>
<ItemTemplate>
<div style="float: left;">
<li class="path-item wow fadeIn" data-wow-delay="0s"><a
class="button round-tiny thin cerulean block"
href="/main_content?con=<%# Eval("b_name") %>" style="width:230px;"><span
class="table"><span class="cell">
<asp:Label ID="b_nameLabel" runat="server" Text='<%# Eval("b_name").ToString.Replace("-", " ") %>' />
</span></span></a></li>
<%--<li class="path-spacer path-spacer-mobile wow fadeIn" data-wow-delay="0s"></li>--%>
</div>
</ItemTemplate>
</asp:ListView>
<asp:SqlDataSource runat="server" ID="data" ConnectionString="<%$ ConnectionStrings:aarogyamindConnectionString %>" SelectCommand="SELECT [b_name] FROM [blog] WHERE ([b_sub_cat] = @b_sub_cat)">
<SelectParameters>
<asp:ControlParameter ControlID="subcatLabel" Name="b_sub_cat" PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</ol>
</div>
</div>
</div>
</ItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:aarogyamindConnectionString %>" SelectCommand="SELECT [subcat] FROM [categories] WHERE ([category] = @category)">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="New-cat" Name="category" QueryStringField="category" Type="String" />
</SelectParameters>
</asp:SqlDataSource>