how to search: treeview

Last post 07-11-2009 11:18 AM by demoninside9. 3 replies.

Sort Posts:

  • how to search: treeview

    07-07-2009, 12:45 AM

    Hi friends

                  I have bounded a treeview to a DB. See there are 3 parent nodes. these parent nodes are having their subnodes even subnodes are having their sub nodes.

    I have bound a grid view so that i can search my data thriugh selecting treeview nodes, subnodes.

    As i told you before there are 3 parent nodes, when I select, suppose I select one parent nodes's subnode the it shows data in gridview which is related to this subnodes. it is fine.

    means every indivisual node or sub node showing their related data.

    Now what i want, I need that if you select a parent node1 then it should show all data related to node1 along with it's all subnodes and subnodes's nodes. Like if you select node1's subnode1 (not node1) then it should show

    all data related to subnode1 along with subnode1's subnode.

    in other way, you can say there are 3 main group every group is having their subgroups(any depth) so if you select any group or sub group then it should show all data related to selected group and its all subgroup's data

    my current query is for searching

    string strSql = "select a.MemberId,a.FirstName,a.LastName,a.Orgnization,a.City from mtblContacts as a INNER JOIN mtblGrpCon as b ON b.MemberId=a.MemberId and b.id=" + TreeView1.SelectedNode.Value + "";

    and adding data to treeview i am using this

    string strSql = "insert into mtblGrpCon(id,MemberId)values('" + TreeView2.SelectedNode.Value + "','" + Label1.Text + "')";

    let me know please

    thank you

    never let you down..always be happy...
  • Re: how to search: treeview

    07-07-2009, 11:48 AM
    • Member
      424 point Member
    • mamun22s
    • Member since 01-10-2008, 12:29 PM
    • Dhaka, Bangladesh
    • Posts 89

    Hi demoninside9

     1st of all its important to know how umanage your data in the data base. I mean is there any parent hild relation. If this you an easily get all the childs of the seleted node. So let me know how you manage you data in database.

     Regards,

    Moinul Hasan
    Senior Software Engineer
    Ennovia Technologies Limited


    (Mark it as answer if it does help you!)
  • Re: how to search: treeview

    07-10-2009, 5:06 AM

    Hi demoninside9,

    First, make sure your db is in different level. I mean main-sub-sub*2-..., so you can know which field I search can display the data for which level. You can get the TreeNode.Depth to identify which level node you click and which field I should filter in select query. I suggest you can use several tables for different level data, so when you click any level node, you can use the node value (usually be the primary or foreign key in tables) to do selecting in query. Then bind GridView.

    Thanks,

    Qin Dian Tang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: how to search: treeview

    07-11-2009, 11:18 AM

    Here is my all Db with diagram alonge with query.

    just check out it may be you can solve my issue..

    http://forums.asp.net/p/1444722/3282623.aspx#3282623

    thanx

    never let you down..always be happy...
Page 1 of 1 (4 items)