none
Display Popup on MouseHover treeview nodes RRS feed

  • Question

  • Hi All,

    I have created a asp tree view and binded tree view recursively to show the data in the treeview . Now i wanted I want to display a pop up on mouse over tree view nodes of that  respective treeview.I have some description for each node in the dataset how to show them in a pop on mouse over. Iam enclosing by code as shown below:

    .ASPX Page:

    <asp:TreeView ID="TreeView1" runat="server" NodeIndent="15" ShowLines="True">
        <HoverNodeStyle Font-Underline="True" ForeColor="#6666AA" />
        <NodeStyle Font-Names="Tahoma" Font-Size="8pt" ForeColor="Black" HorizontalPadding="2px"
            NodeSpacing="0px" VerticalPadding="2px"></NodeStyle>
        <ParentNodeStyle Font-Bold="False" />
        <SelectedNodeStyle BackColor="#B5B5B5" Font-Underline="False" HorizontalPadding="0px"
            VerticalPadding="0px" />
    </asp:TreeView>

    .CS Page:

     {
            if (!this.IsPostBack)
            {
                DataTable dt = this.GetData("[usp_treeview]");
                this.PopulateTreeView(dt, 0, null);
            }
        }

        private void PopulateTreeView(DataTable dtParent, int parentId, TreeNode treeNode)
        {
            foreach (DataRow row in dtParent.Rows)
            {
                TreeNode child = new TreeNode
                {
                    Text = "<SPAN><img style='height:16px;' src='Images/" + row["EmployeeId"].ToString() + ".jpg'></img>" + row["Name"].ToString() + "</SPAN>",
                    Value = row["EmployeeId"].ToString()
                };
                if (parentId == 0)
                {
                    TreeView1.Nodes.Add(child);
                    DataTable dtChild = this.GetData1(child.Value);
                    PopulateTreeView(dtChild, int.Parse(child.Value), child);
                }
                else
                {
                    treeNode.ChildNodes.Add(child);
                    DataTable dtChild = this.GetData1(child.Value);
                    PopulateTreeView(dtChild, int.Parse(child.Value), child);
                }
            }
        }

        private DataTable GetData(string query)
        {
            DataTable dt = new DataTable();
            string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
            using (SqlConnection con = new SqlConnection(constr))
            {
                using (SqlCommand cmd = new SqlCommand(query))
                {
                    using (SqlDataAdapter sda = new SqlDataAdapter())
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Connection = con;
                        sda.SelectCommand = cmd;
                        sda.Fill(dt);
                    }
                }
                return dt;
            }
        }

        private DataTable GetData1(string str_ReportId)
        {
            DataTable dt = new DataTable();
            string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
            using (SqlConnection con = new SqlConnection(constr))
            {
                using (SqlCommand cmd = new SqlCommand("[dbo].[usp_GetEmp_Report]"))
                //using (SqlCommand cmd = new SqlCommand("[dbo].[usp_GetHierarchy]"))
                {
                    using (SqlDataAdapter sda = new SqlDataAdapter())
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@Report_ManagerId", str_ReportId);                    
                        cmd.Connection = con;
                        sda.SelectCommand = cmd;
                        sda.Fill(dt);
                    }
                }
                return dt;
            }
        }


    ram

    • Moved by CoolDadTx Friday, September 15, 2017 2:05 PM ASP.NET related
    Friday, September 15, 2017 6:12 AM

All replies