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

RadDropdownTree.Selected Value cannot be assigned to

5 Answers 611 Views
DropDownTree
This is a migrated thread and some comments may be shown as answers.
Allan
Top achievements
Rank 1
Allan asked on 19 Jun 2013, 09:45 AM
Hi,

I'm trying to pre-check all checkboxes with a RadDropdownTree control after it has been bound to (as per the sample code here) but I am getting a 'RadDropDownTree.SelectedValue' cannot be assigned to -- it is read only' error.

I've had a look about online to check for a versioning issue but couldn't see anything - I'm currently using release 2013.1.403.35, is this the issue?

Thanks,
Allan

5 Answers, 1 is accepted

Sort by
0
Accepted
Peter Filipov
Telerik team
answered on 20 Jun 2013, 07:22 AM
Hi Allan,

The setter functionality comes with Q2.2013. So you need to update in order to use it. In case that it is not possible for you, please use the following approach.

Regards,
Peter Filipov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Paul
Top achievements
Rank 1
answered on 27 Aug 2013, 10:35 AM
I bind my RadDropDownTree using the methods below but whenever I set the SelectedValue it never sets. It's always blank, even though I have checked the SelectedValue is in the datatable.

I use "rdtPOLineItemID.SelectedValue = "pl" + am.POLineID.ToString();" to set the SelectedValue.

I am using Telerik Version 2013.2.717.45

Any help would be greatly appreciated.

Regards, Paul.

private void PopulatePOLineItems()
        {
            rdtPOLineItemID.DataFieldID = "ID";
            rdtPOLineItemID.DataFieldParentID = "ParentID";
            rdtPOLineItemID.DataValueField = "Value";
            rdtPOLineItemID.DataTextField = "Text";
            rdtPOLineItemID.DataSource = BuildDataTable(Convert.ToInt32(Session["ProjectID"]));
            rdtPOLineItemID.DataBind();
        }
 
        private static DataTable BuildDataTable(int projectid)
        {
            DataTable dt = new DataTable();
 
            dt.Columns.Add("ID");
            dt.Columns.Add("ParentID");
            dt.Columns.Add("Value");
            dt.Columns.Add("Text");
 
            DataTable po = cPurchaseOrder.GetAllPurchaseOrdersByProjectID(projectid);
 
            foreach (DataRow dr in po.Rows)
            {
                dt.Rows.Add(new String[] { "p" + dr["purchaseorderid"].ToString(), null, dr["purchaseorderid"].ToString(), dr["purchaseordernumber"].ToString() });
 
                DataTable polines = cPurchaseOrderLineItem.GetPOLineItemsByPOID(Convert.ToInt32(dr["purchaseorderid"].ToString()));
 
                foreach (DataRow podr in polines.Rows)
                {
                    dt.Rows.Add(new String[] { "pl" + podr["polineitemid"].ToString(), "p" + podr["poid"].ToString(), "pl" + podr["polineitemid"].ToString(), podr["polineitemnumber"].ToString() });
                }
            }
 
            return dt;
        }
0
Peter Filipov
Telerik team
answered on 30 Aug 2013, 09:38 AM
Hi Paul,

Please set SelectedValue property after the control is bound. When the value of the property is not found in the Items' values no nodes are checked or selected. To verify that the value exist please handle NodeDataBound event and check for such value.

Regards,
Peter Filipov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Stacy
Top achievements
Rank 1
answered on 22 Apr 2015, 03:05 PM

I have a RadDropDownTree:

<telerik:RadDropDownTree
runat="server"
ID="OrganizationUnitDropDownTree"
Width="250px"
DefaultMessage="Choose a department"
DataTextField="Description"
DataFieldID="OrganizationUnitHierarchyId"
DataFieldParentID="ParentOrganizationUnitHierarchyID"
TextMode="FullPath" >

<DropDownSettings Height="140px" CloseDropDownOnSelection="true" />

</telerik:RadDropDownTree>

 

I want to select an item via server side but cant seem to.  My c# code is:

public void LoadOrgUnitDropDownTree()
{
OrganizationUnitDropDownTree.DataSource = GetData();
OrganizationUnitDropDownTree.DataBind();
OrganizationUnitDropDownTree.ExpandAllDropDownNodes();

OrganizationUnitDropDownTree.SelectedValue = "1";

}

But that does not seem to do anything. 

 My question would be how to select server side based on an id.

I have also tried using "41,33" which is an item  (41) and parent (33) id but that also does not work.

Please advise.

 

 

0
Stacy
Top achievements
Rank 1
answered on 22 Apr 2015, 03:38 PM
Nevermind, I was missing the attribute "DataValueField"
Tags
DropDownTree
Asked by
Allan
Top achievements
Rank 1
Answers by
Peter Filipov
Telerik team
Paul
Top achievements
Rank 1
Stacy
Top achievements
Rank 1
Share this question
or