如何在asp.net中的树节点选择上过滤datalist的数据 [英] how to filter a data of datalist on tree node selection in asp.net

查看:74
本文介绍了如何在asp.net中的树节点选择上过滤datalist的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的树节点: -

this is my tree node:--

<asp:TreeView ID="TreeView1" runat="server" ExpandDepth="0" ImageSet="Arrows">
            <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
            <Nodes>
                
                
                <asp:TreeNode Text="science" Value="New Node">
                    <asp:TreeNode Text="maths" Value="New Node">
                        <asp:TreeNode Text="m1" Value="New Node"></asp:TreeNode>
                        <asp:TreeNode Text="m2" Value="New Node"></asp:TreeNode>
                    </asp:TreeNode>
                </asp:TreeNode>
                <asp:TreeNode Text="12th class" Value="New Node">
                    <asp:TreeNode Text="bio" Value="New Node">
                        <asp:TreeNode Text="doc" Value="New Node">
                            <asp:TreeNode Text="human doc" Value="New Node">
                                <asp:TreeNode Text="mbbs" Value="New Node"></asp:TreeNode>
                            </asp:TreeNode>
                            <asp:TreeNode Text="animal doc" Value="New Node"></asp:TreeNode>
                        </asp:TreeNode>
                    </asp:TreeNode>
                </asp:TreeNode>
            </Nodes>
            <NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" 
                HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" />
            <ParentNodeStyle Font-Bold="False" />
            <SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" 
                HorizontalPadding="0px" VerticalPadding="0px" />
        </asp:TreeView>



现在我想在树节点上点击,然后datalist显示该类别的项目

这是我的datalist :---


now i want as on the tree node i am click then datalist show the item of that category
this is my datalist:---

<asp:DataList ID="dl_books" runat="server" 

        CellPadding="10" RepeatColumns="6" RepeatDirection="Horizontal" 

                onitemcommand="dl_books_ItemCommand">
         
           
              
       <ItemTemplate>
       <div class="slide"> <a href="book-detail.aspx?key1=<%#Eval("Book_id")%>&key2=<%#Eval("Name")%>" ><img src='<%#"book_image/"+ Eval("Image") %>' height="207px" width="140px" alt="" class="pro-img"/></a> <span class="title"><a href="book-detail.aspx"><%#Eval("Name") %></a></span> <span class="rating-bar"><img src="images/rating-star.png" alt="Rating Star"/></span>
            <div class="cart-price"> <asp:ImageButton ID="btn_addtocart" runat="server" ImageUrl="~/images/cart-icon.png" CommandName="Update" CommandArgument='<%#Eval("Book_id") %>' />      <span class="price"><%#Eval("price") %></span></div>
          </div>
       </ItemTemplate>
  </asp:DataList>



现在我要在codebehind上绑定这个datalist

这是我的代码:---


now i am going to bind this datalist on codebehind
this is my code:---

dl_books.DataSource = (from st in obj.Book_details
                                      where st.Category == "math"
                                      orderby st.Book_Id descending
                                      select st).Take(6);
               dl_books.DataBind();



现在我希望按照树节点点击我的datalist应该显示类别项目

???

如何执行此操作?

或者,如果您有任何想法可以在更短的时间内分享完成此任务并使用短代码,那么是否有新想法可以执行此任务请分享


now i want that as per tree node get clicked my datalist should show that category items
???
how to perform this??
Or is there new idea to do this task if you have any idea to share to do this task in less time and with short code then your most welcome please share it

推荐答案

您可以使用Treeview的selectednodechanged事件来获取所选节点值并将Datalist绑定到该节点值。



请参阅以下链接,它会在VB.net中给你一个想法



http://www.4guysfromrolla.com/articles/083006-1.aspx [ ^ ]



希望这有助于
You can use the Treeview's selectednodechanged event to get the selected node value and bind the Datalist with that.

Refer the below link which give you an idea though its in VB.net

http://www.4guysfromrolla.com/articles/083006-1.aspx[^]

Hope this helps


这篇关于如何在asp.net中的树节点选择上过滤datalist的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆