This is a migrated thread and some comments may be shown as answers.

Value is not displaying in text box

5 Answers 91 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Manoj
Top achievements
Rank 1
Manoj asked on 18 Dec 2008, 03:11 PM
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

 

 

 

 

 

 

5 Answers, 1 is accepted

Sort by
0
Manoj
Top achievements
Rank 1
answered on 19 Dec 2008, 10:55 AM
Hi,
    Anybody can help me out ?

With Thanks & Regards
Manoj
0
Veselin Vasilev
Telerik team
answered on 20 Dec 2008, 09:48 AM
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.
0
Iggy
Top achievements
Rank 1
answered on 06 Jan 2009, 04:29 PM
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? 
0
Atanas Korchev
Telerik team
answered on 06 Jan 2009, 05:05 PM
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.
0
Iggy
Top achievements
Rank 1
answered on 07 Jan 2009, 07:23 PM
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.");  
    }  
  }  
Tags
TreeView
Asked by
Manoj
Top achievements
Rank 1
Answers by
Manoj
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Iggy
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or