dynamically populating treeview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jiaudheen
    New Member
    • Jul 2007
    • 19

    dynamically populating treeview

    Hi…I’m new to .net..so pls help me.

    I have a asp.net treview. I need to populate the treview at run time from the sql database. The parent node must be bound from table tblDepartmentDe tails. In this table I have deptCode,deptNa me. I need to populate the parent node with deptName(such as financial,custo mer support.IT,Buis snessDevelopeme mt etc…so as many depts).

    Next I need to populate the child node of each parent node. The child node should be bound from table tblEmployeeDeta ils. In this table I have deptCode,Employ eeNumber,Employ eeName. I need to populate the childnodes with EmployeeNames. Each depts have many employes.

    And atlast if click on any one of the child node(EmpName) the corresponding employe’s EmployeeNumber, EmployeeName and deptName should be displayed in textboxes(txtEm pNum,txtEmpName ,txtDeptName respectivelly).

    Pls help me with deatil C# code.
  • talhaekram
    New Member
    • Apr 2007
    • 14

    #2
    Originally posted by jiaudheen
    Hi…I’m new to .net..so pls help me.

    I have a asp.net treview. I need to populate the treview at run time from the sql database. The parent node must be bound from table tblDepartmentDe tails. In this table I have deptCode,deptNa me. I need to populate the parent node with deptName(such as financial,custo mer support.IT,Buis snessDevelopeme mt etc…so as many depts).

    Next I need to populate the child node of each parent node. The child node should be bound from table tblEmployeeDeta ils. In this table I have deptCode,Employ eeNumber,Employ eeName. I need to populate the childnodes with EmployeeNames. Each depts have many employes.

    And atlast if click on any one of the child node(EmpName) the corresponding employe’s EmployeeNumber, EmployeeName and deptName should be displayed in textboxes(txtEm pNum,txtEmpName ,txtDeptName respectivelly).

    Pls help me with deatil C# code.

    If it is a static database create xml file for your table like this:
    <department>
    <employee>
    </employee>
    </department>
    then map it to your tree.

    Other option is to parse the table to be fit in database.

    1> loop foreach record
    >if dept not found in tree
    >create dept node
    >create new treenode( empname, ..,navigation URL( ..?empNo="+no ) );
    > create child node and add to above node
    > add the above parent node to treeview


    and on page_load use Get["empNo"] and treeview1.selec tdNode.text to textbox

    Comment

    Working...