Copied to clipboard

Flag this post as spam?

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


  • Zobayer Rabbi 3 posts 23 karma points
    Jan 13, 2011 @ 06:58
    Zobayer Rabbi
    0

    Save node property data

    I create a new .net control which will show content data in a DataGridView.  Here is the code

     

    umbraco.presentation.nodeFactory.Node node = new umbraco.presentation.nodeFactory.Node(1243);

                umbraco.presentation.nodeFactory.Nodes childrenNodes = node.Children;

                vessel.DataSource = childrenNodes;

                vessel.DataBind();

                Node node = new Node(1243);

                Nodes childrenNodes = node.Children;

     

                DataTable dt = new DataTable();

                dt.Columns.Add("vesselName");

                dt.Columns.Add("position");

     

                foreach (Node tmp in node.Children)

                {

     

                    DataRow row = dt.NewRow();

     

                    row["vesselName"] = tmp.GetProperty("vesselName").Value;

                    row["position"] = tmp.GetProperty("position").Value;

                    dt.Rows.Add(row);

     

                }

    now i need to save the property data the into the node.
    i made a way out to save directly to umbraco sql database. i think there should be a way to save to through node class. can anyone help me on that?

     

  • Aaron Powell 1708 posts 3044 karma points c-trib
    Jan 13, 2011 @ 07:36
    Aaron Powell
    1

    You need to use the Document API as the Node API works against the XML cache not the database.

    The Document API is part of the cms assembly, and you can basically swap Node for Document and I believe everything is the same (or almost the same).

    If you have a look around the forum you'll find plenty of examples of creating/ editing content programmatically.

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    Jan 13, 2011 @ 08:36
    Dirk De Grave
    0

    As @slace says, use the document api instead of the nodeFactory, and don't go directly into the db, that's asking for trouble..

     

    Cheers,

    /Dirk

  • Jeroen Breuer 4861 posts 12138 karma points MVP 3x admin c-trib
    Jan 13, 2011 @ 09:09
    Jeroen Breuer
    0

    This wiki page might also be helpfull if you want more info about nodes and documents: http://our.umbraco.org/wiki/reference/api-cheatsheet/difference-between-a-node-and-a-document.

    Jeroen

  • 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