Value is not displaying in text box

6 posts, 0 answers
  1. Manoj
    Manoj avatar
    75 posts
    Member since:
    Dec 2008

    Posted 18 Dec 2008 Link to this post

    Hi,
        I am using a tree view control . Based upon the node selection I want to display some text into the text boxes . I have pasted part of my code below.
    But I am not getting any value to the text boxes .

     

     



     

     

    protected void rtvDetailData_NodeExpand(object sender, RadTreeNodeEventArgs e)
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["codingspecialsConnectionString"].ConnectionString);

            SqlCommand selectCommand = new SqlCommand(@"select Heirarchy.childid AS NodeId , Heirarchy.childdescription AS NodeText , Heirarchy.Name, Heirarchy.UPCCode , Heirarchy.CNAN , COUNT(Children.childid) AS ChildCount from Heirarchy LEFT JOIN Heirarchy As Children ON Heirarchy.childid = Children.childid WHERE Heirarchy.ParentID = @parentId GROUP BY Heirarchy.childid , Heirarchy.childdescription , Heirarchy.Name, Heirarchy.UPCCode , Heirarchy.CNAN ", connection);
           

            selectCommand.Parameters.AddWithValue("parentId", e.Node.Value);
            SqlDataAdapter adapter = new SqlDataAdapter(selectCommand);
            DataTable data = new DataTable();
            adapter.Fill(data);
           
            foreach (DataRow row in data.Rows)
            {
                RadTreeNode node = new RadTreeNode();
                node.Text = row["NodeText"].ToString();
                node.Value = row["NodeId"].ToString();

                txtName.Text = row["NodeText"].ToString();
                txtUPCCode.Text = row["UPCCode"].ToString();
                txtCNANNum.Text = row["CNAN"].ToString();
               
                if (Convert.ToInt32(row["ChildCount"]) > 0)
                {
                    node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack;
                }
                e.Node.Nodes.Add(node);
            }
            e.Node.Expanded = true;       
        }

    Can you tell me where I am doing the mistake .

    With Thanks & Regards
    Manoj

     

     

     

     

     

     

  2. Manoj
    Manoj avatar
    75 posts
    Member since:
    Dec 2008

    Posted 19 Dec 2008 Link to this post

    Hi,
        Anybody can help me out ?

    With Thanks & Regards
    Manoj
  3. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 20 Dec 2008 Link to this post

    Hello Manoj,

    In NodeExpand event you cannot update any other control but the TreeView. You can only add nodes to the expanded node.

    You can use the client-side event like OnClientNodePopulated to update any control on the page which fires after the nodes has been added to the expanded node.

    Kind regards,
    Veselin Vasilev
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  4. Iggy
    Iggy avatar
    40 posts
    Member since:
    Jul 2005

    Posted 06 Jan 2009 Link to this post

    Is there a way to send back data from the server that could then be checked in the OnClientNodePopulated function on the client?  For instance, if I wanted to send back a custom message to be displayed in an alert on the client how could that be accomplished? 
  5. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 06 Jan 2009 Link to this post

    Hi Iggy,

    Only the nodes created during the NodeExpand handler are transmitted back to the client. The only possible way is to use a dummy node to transport the data and then remove it.

    Regards,
    Albert
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Iggy
    Iggy avatar
    40 posts
    Member since:
    Jul 2005

    Posted 07 Jan 2009 Link to this post

    Thanks, it works great. 

    Here's how I'm handling it:
    In the code-behind I'm creating a dummy node and adding a custom attribute to it.  The original node (e.node) will then only have one child node.
    RadTreeNode node = new RadTreeNode();  
    node.Attributes["LoginExpired"] = "true";  
    e.Node.Nodes.Add(node);  
     

    Then in the client code, if there is only one node I check if that node has the custom attribute that I added and then am removing the node and doing any other required code:
    function rtvOU_NodePopulated(sender, args) {  
      var childNodes = args.get_node().get_nodes();  
      if (childNodes.get_count() == 1) {  
         //If the user's login expired then we add a dummy node to the tree, here we check for it  
         if (childNodes.getNode(0).get_attributes().getAttribute("LoginExpired")) {  
           //The custom attribute exists so remove the dummy child node  
           childNodes.remove(childNodes.getNode(0));  
     
           //Do any other processing needed  
           alert("Your session has expired.  Please login again to continue.");  
        }  
      }  
Back to Top