Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Guys,
I am using uComponents 5.4.1.0 in Umbraco 6.1.1. I have created datatype grid it has 2 properties number and textstring. Have added property to my doc type called answers. My razor code looks like
@inherits umbraco.MacroEngines.DynamicNodeContext
@using Common.Model
@using System.Xml.Linq
@helper RenderQuestions(dynamic questionsNode){
@foreach (var question in questionsNode.Children)
{
@question.GetPropertyValue(DocumentType.Questions.Question.QuestionText)
@{
dynamic answers = question.GetPropertyValue(DocumentType.Questions.Question.Answers);
@answers.ToXml()
}
var questionsNode = uQuery.GetNodesByType(DocumentType.Questions.Alias).FirstOrDefault();
dynamic qNode = Model.NodeById(questionsNode.Id);
@RenderQuestions(qNode)
/*
if (!string.IsNullOrEmpty(Request.QueryString["recordid"]))
@RenderQuestions()
else
//they have navigated here without filling in data capture form
Response.Redirect("/",true);
}*/
Its erroring on .ToXml() ) string' does not contain a definition for 'ToXml'
Am i missing something?
Regards
Ismail
Have you tried @question.answers.ToXml()
Haven't tested it, just looking at the code samples here : http://ucomponents.org/data-types/datatype-grid/razor-samples/
I just looked in a old project and I used this code with datatype grid before
XDocument doc = XDocument.Parse(propertyvalue); var items = doc.Descendants("item"); foreach (XElement item in items) { item.Element("prop1").Value; item.Element("prop2").Value; }
That seems to work.
Ok just sorted,
var answerXml = Library.ToDynamicXml(question.GetPropertyValue(DocumentType.Questions.Question.Answers));
foreach (var answer in answerXml)
@answer.answer.InnerText
works as well
Nice..that's even cleaner
is working on a reply...
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.
Continue discussion
Datatype grid access data
Guys,
I am using uComponents 5.4.1.0 in Umbraco 6.1.1. I have created datatype grid it has 2 properties number and textstring. Have added property to my doc type called answers. My razor code looks like
@inherits umbraco.MacroEngines.DynamicNodeContext
@using Common.Model
@using System.Xml.Linq
@helper RenderQuestions(dynamic questionsNode){
@foreach (var question in questionsNode.Children)
{
@question.GetPropertyValue(DocumentType.Questions.Question.QuestionText)
@{
dynamic answers = question.GetPropertyValue(DocumentType.Questions.Question.Answers);
@answers.ToXml()
}
}
}
@{
var questionsNode = uQuery.GetNodesByType(DocumentType.Questions.Alias).FirstOrDefault();
dynamic qNode = Model.NodeById(questionsNode.Id);
@RenderQuestions(qNode)
/*
if (!string.IsNullOrEmpty(Request.QueryString["recordid"]))
{
@RenderQuestions()
}
else
{
//they have navigated here without filling in data capture form
Response.Redirect("/",true);
}*/
}
Its erroring on .ToXml() ) string' does not contain a definition for 'ToXml'
Am i missing something?
Regards
Ismail
Have you tried @question.answers.ToXml()
Haven't tested it, just looking at the code samples here : http://ucomponents.org/data-types/datatype-grid/razor-samples/
I just looked in a old project and I used this code with datatype grid before
That seems to work.
Ok just sorted,
var answerXml = Library.ToDynamicXml(question.GetPropertyValue(DocumentType.Questions.Question.Answers));
foreach (var answer in answerXml)
{
@answer.answer.InnerText
}
works as well
Nice..that's even cleaner
is working on a reply...
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.