Thursday, September 27, 2007

New Feature ChildrenAsTable

Umbraco V3 offers many things! and one og them is you now have the posibillity to get you Nodes as a datatable object.
This is great if you love your Usercontrols, repeaters and databinding :)

Niels Hartvig have written an article about how to use the datatable "ChildrenAsTable"

Its a good article, but there is some confusion when you need to get the properties from a node.

Normally when you need a property you retrieves it with the alias, so I tried to make a simple test.
<asp:repeater id="Repeater1" runat="server"><itemtemplate> <a href="'<%#">'><%# Eval("NodeName")%></a> <%# ((DataRowView)Container.DataItem)["umbNaviHide"]%> </itemtemplate></asp:Repeater>

This gave me an error on the umbracoNaviHide, and I thougt whats was wrong with that?

After some debugging I found out that you needs to use the name of the property instead of the Alias, so it looks like this:

<asp:repeater id="Repeater1" runat="server"><itemtemplate>
<a href="'<%#">'><%#Eval("NodeName")%></a>
<%# ((DataRowView)Container.DataItem)["Hide in navigation"]%>

And then it just worked :)

/Happy coding
Read Nielses article here
<a href="" target="_blank">'s-new-in-v3/new-feature-nodefactory-as-datatable-object</a>

No comments:

Post a Comment