Beispiel #1
0
    protected void Tree1_SelectedNodeChanged(object sender, EventArgs e)
    {
        string id = Tree1.SelectedValue;
        //string str = "SELECT  InventorySubSubId, InventorySubSubName FROM  InventoruSubSubCategory where " +          " InventorySubSubName='" + id +"' ";
        string str = "SELECT     InventorySubCategoryMaster.InventorySubCatName,InventoruSubSubCategory.InventorySubSubId, InventoruSubSubCategory.InventorySubSubName, InventoryCategoryMaster.InventoryCatName " +
                     " FROM         InventorySubCategoryMaster INNER JOIN " +
                     " InventoruSubSubCategory ON InventorySubCategoryMaster.InventorySubCatId = InventoruSubSubCategory.InventorySubCatID INNER JOIN " +
                     " InventoryCategoryMaster ON InventorySubCategoryMaster.InventoryCategoryMasterId = InventoryCategoryMaster.InventeroyCatId " +
                     " WHERE     (InventoruSubSubCategory. InventorySubSubName='" + id + "') and InventoryCategoryMaster.compid='" + Session["ClientId"] + "' ";
        SqlCommand     cmd = new SqlCommand(str, con);
        SqlDataAdapter adp = new SqlDataAdapter(cmd);
        DataSet        ds  = new DataSet();

        adp.Fill(ds);
        if (ds.Tables[0].Rows.Count > 0)
        {
            string str2 = "SELECT     InventorySubCategoryMaster.InventorySubCatName, InventoruSubSubCategory.InventorySubSubId, InventoryCategoryMaster.InventoryCatName " +
                          " FROM         InventorySubCategoryMaster INNER JOIN " +
                          " InventoruSubSubCategory ON InventorySubCategoryMaster.InventorySubCatId = InventoruSubSubCategory.InventorySubCatID INNER JOIN " +
                          " InventoryCategoryMaster ON InventorySubCategoryMaster.InventoryCategoryMasterId = InventoryCategoryMaster.InventeroyCatId " +
                          " WHERE     (InventoruSubSubCategory.InventorySubSubId = '" + ds.Tables[0].Rows[0]["InventorySubSubId"].ToString() + " ')";
            SqlCommand     cmd2 = new SqlCommand(str2, con);
            SqlDataAdapter adp2 = new SqlDataAdapter(cmd2);
            DataSet        ds2  = new DataSet();
            adp2.Fill(ds2);



            // Tree1.SelectedNode.Parent.Expand();
            Session["leafnode"]   = ds.Tables[0].Rows[0]["InventorySubSubName"].ToString();
            Session["childnode"]  = ds2.Tables[0].Rows[0]["InventorySubCatName"].ToString();
            Session["parentnode"] = ds2.Tables[0].Rows[0]["InventoryCatName"].ToString();
            Response.Redirect("ProductList.aspx?ProductID=" + ds.Tables[0].Rows[0]["InventorySubSubId"].ToString() + " ");
        }
        else
        {
            Tree1.CollapseAll();
            Tree1.SelectedNode.ToggleExpandState();
            foreach (TreeNode node in Tree1.Nodes)
            {
                foreach (TreeNode cnode in node.ChildNodes)
                {
                    if (Tree1.SelectedNode == cnode)
                    {
                        cnode.Parent.Expand();
                    }
                }
            }
        }
    }