Try our conversational search powered by Generative AI!

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
Feb 22, 2008 13:58
Vote:
 
The XFormStatistics class has a property NumberOfVotes which gets the number of votes that was returned.
#16796
Feb 22, 2008 15:20
Vote:
 
Thank you. But this returns the total number of counts. i need individual option count.
#16797
Feb 25, 2008 5:30
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
Feb 26, 2008 13:57
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.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.