AI OnAI Off
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.Adapters;
using System.Web.UI.WebControls;
using EPiServer;
using EPiServer.WebControls;
using EPiServer.XForms;
using EPiServer.XForms.WebControls;
namespace XFormX
{
public class RenderSample : ControlAdapter
{
protected override void CreateChildControls()
{
XFormStatistics xformStat = Control as XFormStatistics;
xformStat.Controls.Add( new LiteralControl("This is rendered using a ControlAdapter
"));
foreach(XFormData formData in xformStat.Statistics)
{
xformStat.Controls.Add( new LiteralControl(String.Format( "Dateposted: {0}
", formData.DatePosted)));
}
xformStat.Controls.Add( new LiteralControl( "
" ) );
}
}
}
2)
Then, save the below xml into a file named 'something'.browser into the folder App_Browsers of your EPiServer directory. Create the App_Browsers directory if it doesnt alread exist.
Now, all rendering of XFormStatistics is done through our controladapter, which simply lists the dateposted for every post of the form - you may want to change this logic :)
Regards,
Johan Olofsson
EPiServer AB
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.Adapters;
using System.Web.UI.WebControls;
using System.Collections.Generic;
using EPiServer;
using EPiServer.WebControls;
using EPiServer.XForms;
using EPiServer.XForms.WebControls;
namespace XFormX
{
public class RenderSample : ControlAdapter
{
protected override void CreateChildControls()
{
XFormStatistics xformStat = Control as XFormStatistics;
Dictionary formFields = new Dictionary();
foreach(XFormData d in xformStat.Statistics)
{
foreach(System.Xml.XmlNode n in d.Data.GetElementsByTagName( "instance" )[0].ChildNodes)
{
String name = n.LocalName;
String val = HttpContext.Current.Server.HtmlEncode( n.InnerText );
if(!formFields.ContainsKey( name ))
{
FormFieldStatistic tmpStatistic = new FormFieldStatistic( name );
tmpStatistic.AddEmptyVote( val );
formFields.Add( n.LocalName, tmpStatistic );
}
( (FormFieldStatistic)formFields[name] ).AddVote( val );
}
}
// do something with
foreach(string key in formFields.Keys)
{
FormFieldStatistic ffs = formFields[key];
Control.Controls.Add( new LiteralControl(String.Format("{0} : {1} votes
", ffs.FieldName, ffs.Votes.Count )));
}
}
}
}
/johan