1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Polls archive or content view

Polls archive or content view

2 posts, 0 answered
  1. Damian
    Damian avatar
    42 posts
    Registered:
    25 Mar 2008
    22 Sep 2008
    Link to this post
    All,

    I am trying to create a paged list of polls picked up from the polls module.

    This is so I don't have to drag a poll box on everytime I add one to the module.

    What would you suggest be the best way to acheive this.

    I have tried the content view control and the archive control by setting the data provider to polls, but I just get the message "No provider with name 'Polls' has not been set".

    Thanks in advance

    Damian
  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    24 Sep 2008
    Link to this post
    Hi Damian,

    Polls module is not a Generic Content based module. That is the reason why you can not use Content View controls to list all polls. To achieve the required functionality you need to implement your own control using Polls API. Here is a sample implementation of a user control that creates a PollBox control for every poll item:

    .ascx
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="PollsView.ascx.cs" Inherits="PollsView" %> 
     
    <asp:PlaceHolder ID="polls" runat="server"></asp:PlaceHolder> 

    ascx.cs
    using System; 
    using System.Collections; 
    using System.Configuration; 
    using System.Data; 
    using System.Web; 
    using System.Web.Security; 
    using System.Web.UI; 
    using System.Web.UI.HtmlControls; 
    using System.Web.UI.WebControls; 
    using System.Web.UI.WebControls.WebParts; 
    using Telerik.Polls; 
    using System.Collections.Generic; 
    using Telerik.Polls.WebControls; 
     
    public partial class PollsView : System.Web.UI.UserControl 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            PollManager pollManager = new PollManager(); 
            IList<IPollItem> listOfPolls = pollManager.GetAllPolls(); 
             
            foreach (IPollItem poll in listOfPolls) 
            { 
                Guid pollId = poll.ID; 
                PollBox box = new PollBox(); 
                box.PollId = pollId; 
                this.polls.Controls.Add(box); 
            } 
        } 
     

    Do let us know if you need any further assistance.

    Sincerely yours,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
2 posts, 0 answered