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
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
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;
}
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
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.