checkedNodes count 0

3 posts, 0 answers
  1. Christian
    Christian avatar
    69 posts
    Member since:
    Apr 2008

    Posted 03 Mar 2011 Link to this post

    Visual Studio 2008
    .Net 3.5 SP1
    Ajax controls (Q3 2010)

    I always get count 0 when trying to get the checkedNodes from the treeview, i need to get the value of the node (can only be one checked node that is controlled by a javascript) and when i finally do a postback i want to get the value and do an insert into a database, cant really se the problem, is there any event that i have set wrong? seems that the client dousent set the node to checked or the server cant seem to find the checked node some how.

    On page load i bind the treeview from a seperate method, 
    protected void Page_Load(object sender, EventArgs e)
            UI ui = GetUI();
            //if (!IsPostBack)
            //    BindTvCaseType(ui);
            if (Session[Common.userSession] == null || ((AdManager.UserInfo)Session[Common.userSession]).Status == AdManager.LoginStatus.Error)
            //UI ui = GetUI();
            BindTvCaseType(ui); //This is where i bind the treeview
            ui.tvType.ID = "tvCaseType";
            ui.labEmail.Text = (((AdManager.UserInfo)Session[Common.userSession]).Email);
            if ((((AdManager.UserInfo)Session[Common.userSession]).Email) == "")
                ui.panEmailNotification.Visible = false;
            ui.btnStep2.Attributes.Add("OnClick", "checkStep1(); return false;");
            ui.btnStep3.Attributes.Add("OnClick", "checkStep2(); return false;");

    The bind method
    private void BindTvCaseType(UI ui)
            dsHelpdeskG2TableAdapters.typesTableAdapter taCaseTypes = new dsHelpdeskG2TableAdapters.typesTableAdapter();
            dsHelpdeskG2.typesDataTable dtCaseTypes = taCaseTypes.GetData();
            ui.tvType.Nodes.AddRange(TreeviewBuilder.BuildRecursive(null, 0, null, dtCaseTypes, null));

    Treeviewbuilder method thats used above, to build the tree
    public static List<RadTreeNode> BuildRecursive(dsHelpdeskG2.typesRow drNodeRow, int rowLevel, dsHelpdeskG2.permissionsDataTable dtPermissions, dsHelpdeskG2.typesDataTable dtTypes,
            AdManager.UserInfo us)
            List<RadTreeNode> nodeList = new List<RadTreeNode>();
            if (rowLevel > 5)
                return nodeList;
            int c_ty_id = 0;
            if (drNodeRow != null)
                c_ty_id = drNodeRow.ty_id;
            var nodeTable = from c in dtTypes
                            where c.ty_parent_id == c_ty_id
                            orderby c.ty_id
                            select c;
            foreach (var nodeRow in nodeTable)
                RadTreeNode node = new RadTreeNode();
                node.Value = nodeRow.ty_id.ToString();
                node.Text = nodeRow.ty_name;
                node.Nodes.AddRange(BuildRecursive(nodeRow, rowLevel + 1, dtPermissions, dtTypes, us));
                //node.ID = "tvTypeNode" + nodeRow.ty_id;
                if (node.Nodes.Count > 0)
                    //om den inte har childs
                    node.Checkable = false;
                    //har childs..
            return nodeList;

    button, postback to make insert, cant get values (always count 0)
    protected void btnSendCase_Click(object sender, EventArgs e)
        UI ui = GetUI();
        dsHelpdeskG2TableAdapters.casesTableAdapter dtaCases = new dsHelpdeskG2TableAdapters.casesTableAdapter();
        double anstId = ((AdManager.UserInfo)Session[Common.userSession]).AnstId;
        var temp = Request.Params;
        int caseTypeId = int.Parse(ui.tvType.CheckedNodes[0].Value); //This is where i set a int value and trye to retreave the checked node.
        int caseSeverity = int.Parse(ui.cmbSeverity.SelectedValue);
        int caseCharacter = int.Parse(ui.cmbCharacter.SelectedValue);
        string userIP = Request.ServerVariables["REMOTE_ADDR"];
        string userHostname = Request.ServerVariables["REMOTE_HOST"];
        string caseHeader = ui.txtRubrik.Text;
        bool caseNotification;
        if (ui.rbEmailYes.Checked)
            caseNotification = true;
            caseNotification = false;
        dtaCases.Insert(anstId, null, caseTypeId, caseSeverity, caseCharacter, DateTime.Now, userIP, null, caseHeader, 1, caseNotification, null, null, userHostname);

    Treeview inside combobox (ASPX)
    <telerik:RadComboBox ID="cmbCaseType" runat="server" Skin="Windows7" Height="160px" Style="vertical-align: middle;" Width="225px">
    <div id="div1">
                        <telerik:RadTreeView ID="tvCaseType" runat="server" CheckBoxes="True" Height="160px" Width="100%" OnClientNodeChecked="nodeClicking">
    <telerik:RadComboBoxItem Text="" />
    <CollapseAnimation Type="None" /><ExpandAnimation Type="None" /> 
    </telerik:RadComboBox><br />



    asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="checkTypeTreeview" ErrorMessage="CustomValidator" Display="Dynamic" ValidationGroup="Step1">Vnligen ange En rendetyp</asp:CustomValidator











    Javascript, OnClientNodeChecked from treeview above
    var oldNode;
    function nodeClicking(sender, args)
        var comboBox = $find("ctl00_phContent_pbCaseRegistration_i0_i0_cmbCaseType");
        var node = args.get_node()
        if(oldNode != null)
        oldNode = node;

    Javascript event from validator in aspx above
    function checkTypeTreeview(source, arguments) 
         var treeView = document.getElementById("ctl00_phContent_pbCaseRegistration_i0_i0_cmbCaseType_i0_tvCaseType");     
         var checkBoxes = treeView.getElementsByTagName("input");
         var checkedCount = 0;     
         for (var i = 0; i < checkBoxes.length; i++)
            if (checkBoxes[i].checked) 
         if (checkedCount > 0 && checkedCount < 2) 
         arguments.IsValid = true;
         arguments.IsValid = false;     
  2. Christian
    Christian avatar
    69 posts
    Member since:
    Apr 2008

    Posted 04 Mar 2011 Link to this post

    I was so focused on the treeview that i dident check my other controls values, and None of my controls have any values, Comboboxes . all get value 0.

    Forgot to mention that the controls are all placed within a radpanelbaritem, and the button that does the postback is in index 3 of the panelbaritems.

  3. Dimitar Terziev
    Dimitar Terziev avatar
    1268 posts

    Posted 10 Mar 2011 Link to this post

    Hi Christian,

    Since you have already opened a support ticket regarding this problem, which seems to be related only to your specific scenario, we will continue discussing the problem in the above mentioned support ticket.

    All the best,
    Dimitar Terziev
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top