Copied to clipboard

Flag this post as spam?

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


  • Touhid 97 posts 117 karma points
    Jan 06, 2011 @ 11:10
    Touhid
    0

    for each loop in .net user control

    Hi

    I have some child node, like:

    parent

     --child1

    --child2

    --child3

    etc

    So how can i apply loop in .net user control for get child node.

     

    Touhid

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jan 06, 2011 @ 11:28
    Jan Skovgaard
    0

    Hi Touhid

    In your codebehind for the user control you need to write some C# to do it.

    Here is some information about foreach loops in C# http://msdn.microsoft.com/en-us/library/ttw7t8t6%28v=vs.71%29.aspx and http://dotnetperls.com/foreach

    With the above in combination with the API stuff you can see on the wiki pages in here I think you have a good starting point.

    Happy coding

    /Jan

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Jan 06, 2011 @ 11:36
    Stefan Kip
    0

    Also have a look at the ASP Repeater control: http://articles.sitepoint.com/article/asp-net-repeater-control

  • Touhid 97 posts 117 karma points
    Jan 06, 2011 @ 13:06
    Touhid
    0

    Hi

    Thnks for reply and i have done it following this way :

    umbraco.presentation.nodeFactory.

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

    umbraco.presentation.nodeFactory.

    Nodes childrenNodes = node.Children;

     

    foreach (Node doc in childrenNodes)

    {

    MomentumLabel.Text = doc.GetProperty(

    "vesselName").Value;

    momentumPositionTextBox.Text = doc.GetProperty(

    "position").Value;

    momentumDateTextBox.Text = doc.GetProperty(

    "date").Value;

    momentumDirTextBox.Text = doc.GetProperty(

    "dir").Value;

    }

    Touhid

  • Touhid 97 posts 117 karma points
    Jan 06, 2011 @ 13:52
    Touhid
    0

    Hi

    I have an another problem when i was used gridview:

    umbraco.presentation.nodeFactory.

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

    umbraco.presentation.nodeFactory.

    Nodes childrenNodes = node.Children;

     

    foreach (Node doc in childrenNodes)

    {

     

    GridView gvRow = new GridView();

     

    foreach (GridViewRow row in childrenNodes)

    {

    row.Cells[0].Text = doc.GetProperty(

    "vesselName").Value;

    row.Cells[1].Text = doc.GetProperty(

    "position").Value;

    row.Cells[2].Text = doc.GetProperty(

    "date").Value;

    row.Cells[3].Text = doc.GetProperty(

    "dir").Value;

    }

     

    }

    Errror:

    Unable to cast object of type 'umbraco.presentation.nodeFactory.Node' to type 'System.Web.UI.WebControls.GridViewRow'.

    Where is my problem? i cant understood it.

    Pls help me.

     

    Touhid

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Jan 06, 2011 @ 14:01
    Stefan Kip
    0
    foreach (GridViewRow row in childrenNodes)

    This is impossible ;-)

  • Touhid 97 posts 117 karma points
    Jan 06, 2011 @ 14:11
    Touhid
    0

    So How can i solve it?

    pls help me.

Please Sign in or register to post replies

Write your reply to:

Draft