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

multiple node selection

4 Answers 83 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 12 Sep 2008, 01:57 PM
does the c# example here http://demos.telerik.com/aspnet/prometheus/TreeView/Examples/Functionality/MultipleSelect/DefaultCS.aspx look correct?

I am trying to write the multiply selected tree nodes to a label - It seemed the node_click event would be what i need - however I've seen others have had some issues with it and apparently i am not going down the right path.

I don't see how to set the radtreeview control to autopostback = true

here is what i attempted

using

System;

using

System.Data;

using

System.Configuration;

using

System.Collections;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Web.UI.HtmlControls;

using

System.Data.SqlClient;

using

Telerik.Web.UI;

public

partial class radman : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

RadTreeView1.DataSource = createOrgTreeTable();

RadTreeView1.DataFieldID =

"OrgId";

RadTreeView1.DataFieldParentID =

"OrgParent";

RadTreeView1.DataTextField =

"Name";

RadTreeView1.DataValueField =

"Name";

RadTreeView1.MultipleSelect =

true;

RadTreeView1.DataBind();

}

private DataTable createOrgTreeTable()

{

SqlConnection sqlConn = new SqlConnection(TPWConfiguration.DbConnectionString);

sqlConn.Open();

SqlCommand CmdRoot = new SqlCommand("tpw_direct_reports_listing_all", sqlConn);

CmdRoot.CommandType =

CommandType.StoredProcedure;

CmdRoot.Parameters.Add(

new SqlParameter("@UserId", SqlDbType.VarChar));

CmdRoot.Parameters[

"@UserID"].Value = "jjb000;

DataTable dtOrgTree = new DataTable();

dtOrgTree.Columns.Add(

"OrgId");

dtOrgTree.Columns.Add(

"OrgParent");

dtOrgTree.Columns.Add(

"login");

dtOrgTree.Columns.Add(

"name");

SqlDataAdapter daRoot = new SqlDataAdapter(CmdRoot);

daRoot.Fill(dtOrgTree);

return dtOrgTree;

}

protected void ShowSelected()

{

lblSelectedNodes.Text =

"";

foreach (RadTreeNode node in RadTreeView1.SelectedNodes)

{

lblSelectedNodes.Text +=

"<br/>" + node.FullPath;

}

}

protected void Button1_Click(object sender, EventArgs e)

{

ShowSelected();

}

}

4 Answers, 1 is accepted

Sort by
0
Jeff
Top achievements
Rank 1
answered on 16 Sep 2008, 07:27 PM
still looking for how i can write the multiple selected nodes to a label so we can pass them into a stored procedure....

can you advise - there could be an order coming - not that you haven't heard that before - but it's true if this can do it's thing.
0
Yana
Telerik team
answered on 17 Sep 2008, 07:27 AM
Hi Jeff,

Please modify the code in your Page_Load method like this:

if (!IsPostBack)  
{  
    RadTreeView1.DataSource = createOrgTreeTable();  
    RadTreeView1.DataFieldID = "OrgId";  
    RadTreeView1.DataFieldParentID = "OrgParent";  
    RadTreeView1.DataTextField = "Name";  
    RadTreeView1.DataValueField = "Name";  
    RadTreeView1.MultipleSelect = true;  
    RadTreeView1.DataBind();  

because now RadTreeView is created on every postback and loses its selection.

Regards,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jeff
Top achievements
Rank 1
answered on 17 Sep 2008, 01:21 PM
ok that worked - except i don't want the full path - yet the underlying datavalue field of the clicked node. How would i get those values?  The example shows fullpath - i need childpath but i don't see such a property.
0
Yana
Telerik team
answered on 17 Sep 2008, 01:51 PM
Hello Jeff,

You can simply use node.Text or node.Value.

Regards,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
Jeff
Top achievements
Rank 1
Answers by
Jeff
Top achievements
Rank 1
Yana
Telerik team
Share this question
or