ASP.NET VB Nested Listviews problem with the inner listview

36 Views Asked by At

I am trying to make nested listview. but the inner listview did not displaying. outer is displaying.

I have outer listview and inner listview. each has its own sqldatasource. the problem is I cannot get the "subcat" to the inner listview and that is why the second listview does not contain any data.

    <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>

I tried everything like changing the property name and controller name.

1

There are 1 best solutions below

0
Prince Jodhani On

Yes, It is solved.

here is my code with successful execution.

<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>