I am trying to Count All Responces in Survey List Programmatically by using Camel query ........
i have done in below code 1)bind the question 2)bind the choice field(response of single user )
and now trying to count all users responses and calculate percentages of responses programmatically
foreach (SPListItem item in collitem) { string v = new SPFieldUserValue(web, item["Author"].ToString()).User.ToString(); HtmlGenericControl que = new HtmlGenericControl("p");
var fields = item.Fields;
foreach (SPField field in fields)
{ if (field.Type == SPFieldType.Choice) {
SPFieldChoice choiceField;
choiceField = (SPFieldChoice)field;
que = new HtmlGenericControl("p");
que.InnerHtml = field.Title + "</br>";
SPQuery responseQuery = new SPQuery();
responseQuery.Query = @"
<IsNotNull><FieldRef Name='" + field.InternalName + "' /></IsNotNull></Where>";
var res = list.GetItems(responseQuery);
foreach (SPListItem itm in res)
{
que.InnerHtml += "Answer: " + itm[field.InternalName].ToString();
}
resultDiv.Controls.Add(que);
this.Controls.Add(resultDiv)
}
}
}

0 commentaires:
Enregistrer un commentaire