How to get poll count?

Vote:
 
Hi I used the following code to get the Poll Count. But i need only the count and not the graph. Can you suggest how to achieve this.
#16008
Mar 25, 2008 19:07
Vote:
 
The XFormStatistics class has a property NumberOfVotes which gets the number of votes that was returned.
#16796
Mar 25, 2008 19:19
Vote:
 
Thank you. But this returns the total number of counts. i need individual option count.
#16797
Mar 25, 2008 19:19
Vote:
 
Ok, then you need to iterate through the statistic result set. You should try code similar to this (where xformStat is your XFormStatistics control object): 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 ); } } 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 ))); }
#16798
Mar 25, 2008 19:19
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.