The following sample code shows how you can delete a poll answer.
[C#]
using CMS.Polls; using CMS.SettingsProvider; using CMS.DataEngine; using CMS.GlobalHelper;
...
string pollName = "testingpoll";
// Get poll info for the specified code name PollInfo pollObj = PollInfoProvider.GetPollInfo(pollName);
if (pollObj != null) { // Get all poll answers DataSet answers = PollAnswerInfoProvider.GetAnswers(pollObj.PollID);
if (!DataHelper.DataSourceIsEmpty(answers)) { // Create pollanswerinfo object from datarow PollAnswerInfo pollAnswerObj = new PollAnswerInfo(answers.Tables[0].Rows[0]);
if (pollAnswerObj != null) { // Delete poll answer PollAnswerInfoProvider.DeletePollAnswerInfo(pollAnswerObj.AnswerID);
lblInfo.Text = "The poll answer was deleted successfully."; } else { this.lblInfo.Text = "Failed to delete the poll answer."; } } else { this.lblInfo.Text = "No poll answers found."; } } |
Page url: http://devnet.kentico.com/docs/devguide/index.html?deleting_a_poll_answer.htm