Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • All Blonde 86 posts 138 karma points
    Aug 14, 2012 @ 16:39
    All Blonde
    0

    what is wrong here,code is exactly how it is in video for data binding

    Hi guys,

    pleazse advise what is wrong. I used exact code as it shown in Umbraco TV:

    ==================================================================

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    using umbraco.cms.businesslogic.web;
    using umbraco.BusinessLogic;
    using umbraco.presentation.nodeFactory;

    namespace Campus
    {
        public partial class ProgramsControl : System.Web.UI.UserControl
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    foreach (Node n in Node.GetCurrent().Children)
                    {
                      
                        parentPage.Items.Add(new ListItem(n.Name, n.Id.ToString()));
                    }
                }

            }
        }
    }

     

    =================================================================

     

    but VS2010 show follwoing errors right away:

    =================================================================

    Error    5    The name 'parentPage' does not exist in the current context    C:\Temp\campus-com\web\usercontrols\ProgramsControl.ascx.cs    23    21    BOA


    ================================================================

    Page is regular control and I have references to all 3 DLL as shown in video.

    Thanks

     

     

  • Sandro 45 posts 118 karma points c-trib
    Aug 14, 2012 @ 17:18
    Sandro
    0

    What does your .ascx look like? I guess you simply have no object called 'parentPage'...

    Also: Consider using umbraco.NodeFactory.Node instead of umbraco.presentation.nodeFactory.Node, because the latter is marked as obsolet.

  • All Blonde 86 posts 138 karma points
    Aug 14, 2012 @ 19:20
    All Blonde
    0

    Hey Sandro, thanks for reply.

    ASCX looks like that:

     

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ProgramsControl.ascx.cs" Inherits="Campus.ProgramsControl" %>
    <%@ Register Namespace="umbraco.uicontrols" Assembly="controls" TagPrefix="umb" %>
    <p>
    <asp:Literal runat="server" ID="ltr_programslist"></asp:Literal>
    </p>

     

    And I did try to use umbraco.NodeFactory.Node.

    Did not do any difference.

  • Bo Damgaard Mortensen 719 posts 1207 karma points
    Aug 14, 2012 @ 23:54
    Bo Damgaard Mortensen
    0

    Hi All,

    Could it be that you're missing a variable declaration? :-) I don't see any variable with the name "parentPage" in your code.

  • Sandro 45 posts 118 karma points c-trib
    Aug 15, 2012 @ 07:26
    Sandro
    0

    There should be a Dropdownlist control on the .ascx with the name 'parentPage'. You can see it at Minute 2:23 of the video:

    Also on Minute 8:27 you can see it in action, where the values get bound to the control.

  • All Blonde 86 posts 138 karma points
    Aug 15, 2012 @ 15:35
    All Blonde
    0

    Thanks,

    I found different aproach to problem at hands.

    Thanks for reply anyway.

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies