Copied to clipboard

Flag this post as spam?

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


  • Sa 118 posts 152 karma points
    Jan 13, 2010 @ 06:45
    Sa
    0

    how to retrieve contents of specific selected node

    Hi folks.,

    how to retrieve contents of particular selected node

    for example:

    if i select "something2" in the below sample its content should be retrieved..

    i am not using xslt here .is there any other way to do it?

    +Content
       
    +RootOfWebsite (redirects to Home)
           
    +Home
               
    +page1
               
    +page2
               
    +page3
           
    +Something2
               
    +page1
               
    +page2
               
    +page3
           
    +Something3
           
    +Something4
           
    +Something5
  • vijay 129 posts 152 karma points
    Jan 13, 2010 @ 08:05
    vijay
    0

    Hi sam,

    Can u give clear idea what u want to do to me.

    if u want to read contents / document types inside the node u have to use following code

    Document doc = new Document(NodeID));
                txt_QText.Text = doc.getProperty("QuestionText").Value.ToString();

    -----------------------------------------------------------------------------------------------------------------------------

    If u want to get child nodes below Something2 below code is used to display Page1,Page2,Page3 in dropdown

    private void Fill_DD_Category()
        {
            string st = string.Empty;
            DataTable dt;
            dt = new DataTable();

            dt.Columns.Add(new DataColumn("nodeName", typeof(string)));
            dt.Columns.Add(new DataColumn("nodeid", typeof(string)));
            DataRow dr;
            dr = dt.NewRow();
            dr["nodeName"] = "Please select category";
            dr["nodeid"] = "0";
            dt.Rows.Add(dr);

            Node CurrentNode = Node.GetCurrent();
            Nodes nodes = CurrentNode.Children;

            foreach (Node node in nodes)
            {
                if (node.NodeTypeAlias == "Something2")
                {
                    dr = dt.NewRow();
                    dr["nodeName"] = node.Name;
                    dr["nodeid"] = node.Id;
                    dt.Rows.Add(dr);

                    st = st + "/" + node.Name;
                }
            }
            Response.Write(dt);
            DD_Category.DataTextField = "nodeName";
            DD_Category.DataValueField = "nodeid";
            DD_Category.DataSource = dt;
            DD_Category.DataBind();
        }

    Hope this helps,

    cheers

    vijay.

  • Sa 118 posts 152 karma points
    Jan 13, 2010 @ 08:11
    Sa
    0

    to be precise i need to retreive content of particlar selected node alone and not its child content

  • Sa 118 posts 152 karma points
    Jan 13, 2010 @ 09:02
    Sa
    0

    thank you Vijay.

    i got clue from your post

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 13, 2010 @ 11:04
    Dirk De Grave
    0

    Sam,

    vijay's sample is perfect, but be aware of the fact that you should only use the document api if you're working in the backend (umbraco admin site). If you're on the frontend, you should use the nodeFactory.Node class (see my blog post on this)

     

    Cheers,

    /Dirk

  • vijay 129 posts 152 karma points
    Jan 13, 2010 @ 11:40
    vijay
    0

    hi sam,

    when u want to retrive the Particular Node Contents

    put below code in xslt file


    <xsl:choose>
    <xsl:when test="count(Farmscape-FAQ/node[@nodeTypeAlias='Something2'])&lt;=0">
    <div id="NoComments">
        There are no comments yet... be the first to make one ...
    </div>
    </xsl:when>
    <xsl:otherwise>

    <xsl:for-each select="Farmscape-FAQ/node[@nodeTypeAlias='Something2']">
        <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a> (<xsl:value-of select="count(node[@nodeTypeAlias='DocumentTypeAlias'])"/>)
    </xsl:for-each>


    </xsl:otherwise>
    </xsl:choose>

    cheers

    vijay.

     

  • vijay 129 posts 152 karma points
    Jan 13, 2010 @ 11:44
    vijay
    0

    Thanks for your reply sam

    cheers

    vijay

Please Sign in or register to post replies

Write your reply to:

Draft