the easiest way is probably by using XSLT, I have attached a simple example on the project page (look under screenshots). E.g. if your Embedded Content control has the alias 'productSpecifications', is located on the current page and has 2 properties with alias 'name' and 'value', you could do something like this:
Hope that makes sense. I'll upload a new, pretty much reworked version of the datatype in a bit, the frontend stays the same but the backend has had a good revamp due to some issues that have come up. IE made my life quite hard here, but it seems like I'll have the upper hand for now.
if (!string.IsNullOrEmpty(surveyAnswers)) { XmlDataSource ds = new XmlDataSource(); ds.Data = surveyAnswers; ds.EnableCaching = false;
Repeater Repeater1 = new Repeater();
Repeater1.DataSource = ds; Repeater1.DataBind();
foreach (RepeaterItem item in Repeater1.Items) { var name = XPathBinder.Eval(item.DataItem, "./name"); var value = XPathBinder.Eval(item.DataItem, "./value");
I'm building all dynamic in codebehind so can't add a controls in design view. ended up using child nodes which works fine- but i don't like having nodes in my tree which are not pages
How do I loop through the contents of embedded content
Hello,
How can I loop through the items inside the embedded content?
Hi Sherry,
the easiest way is probably by using XSLT, I have attached a simple example on the project page (look under screenshots). E.g. if your Embedded Content control has the alias 'productSpecifications', is located on the current page and has 2 properties with alias 'name' and 'value', you could do something like this:
<ul>
<xsl:for-each select="$currentPage/productSpecifications[@isDoc]/data/item">
<li>
<xsl:value-of select="./name">: <xsl;value-of select="./value">
</li>
</xsl:for-each>
</ul>
Hope that makes sense. I'll upload a new, pretty much reworked version of the datatype in a bit, the frontend stays the same but the backend has had a good revamp due to some issues that have come up. IE made my life quite hard here, but it seems like I'll have the upper hand for now.
Cheers, Sascha
For those of you looking for a .net usercontrol sample using a repeater:
Anyway to do that without a repeater?
You should be able to use a GridView as well - just set the gridview datasource & then databind it. Or did you mean using something else?
I would like to make a simple for-loop like in xslt..
Tried your example but could'nt get my value out.
string surveyAnswers = node.GetProperty("surveyAnswers").Value;
if (!string.IsNullOrEmpty(surveyAnswers))
{
XmlDataSource ds = new XmlDataSource();
ds.Data = surveyAnswers;
ds.EnableCaching = false;
Repeater Repeater1 = new Repeater();
Repeater1.DataSource = ds;
Repeater1.DataBind();
foreach (RepeaterItem item in Repeater1.Items)
{
var name = XPathBinder.Eval(item.DataItem, "./name");
var value = XPathBinder.Eval(item.DataItem, "./value");
lit.Text += name + " :: " + value + "<br />";
}
// Test!
lit.Text += "all answers " + node.GetProperty("surveyAnswers").Value + "\n\n";
}
Did you hook up your repeater to the ItemDataBound event in the source code (not codebehind)?
Based on your example, I would try something like (untested code, so make adjustments as required):
I'm building all dynamic in codebehind so can't add a controls in design view. ended up using child nodes which works fine- but i don't like having nodes in my tree which are not pages
is working on a reply...