Copied to clipboard

Flag this post as spam?

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


  • Barry 99 posts 187 karma points
    Aug 27, 2009 @ 14:23
    Barry
    0

    Querying Umbraco nodes

    On my site I have a dropdown on a .net control , I'd like to populate this with child nodes that.

    1. Where the EventDate is current (greater than today)

    2. Where the child node is not hidden.

     

    EventsNode.ChildrenAsTable(); - will get the children but how do I restrict the children by my criteria?

     

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Aug 27, 2009 @ 16:01
    Thomas Höhler
    0

    You can use a DataView instead of the DataTable

    System.Data.DataTable dt = Node.GetCurrent().ChildrenAsTable();
    System.Data.DataView dv = new System.Data.DataView(dt);
    dv.RowFilter = "YOUR FILTER EXPRESSION";
    // Bind the DataView to the DropDown

    hth, Thomas

  • Barry 99 posts 187 karma points
    Aug 27, 2009 @ 18:24
    Barry
    0

    If the EventDate is held as a date - can I filter like this:

     

        dv.RowFilter = "[EventDate] > " + DateTime.Today.ToString();

  • Barry 99 posts 187 karma points
    Aug 27, 2009 @ 19:25
    Barry
    0

    hmmm cant seem to get the date filtering working..

     

    // [Date] = The name of the field , not the alias as required.

     

    dv.RowFilter = "[Date] > " + DateTime.Today.ToString();

    dv.RowFilter = "[Date] > '" + DateTime.Today.ToString() + "'";

    None of these work.. any ideas? The datatype for the [Date] field is date datatype. Needs to work irrespective of date/international settings of server.

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Aug 27, 2009 @ 20:06
    Nik Wahlberg
    0

    I think you could do something like this:

    dv.RowFilter = String.Format(CultureInfo.InvariantCulture.DateTimeFormat,
    "Date = #{0}#", DateTime.Today.ToString());

    Thanks,
    Nik

  • 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