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

Forums / Developing with Sitefinity / Working with EventView (ContentView in general)

Working with EventView (ContentView in general)

4 posts, 0 answered
  1. Nigel
    Nigel avatar
    49 posts
    Registered:
    07 Jul 2008
    25 Aug 2009
    Link to this post
    Hi, I am implementing a custom implementation of Event listing and this is fine, but I am having problems when it comes to displaying the selected event in an eventview control.
    I have a page with a grid view that when an event is selected I wish to pass that event into the eventview and have it display the details of the event.

    How do you pass in the event that you want to view. I have tried ID = {GUID} on the filter string, but this dosn't seem to work.

    Any help here would be appreciated
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    25 Aug 2009
    Link to this post
    Hi Nigel,

    Generally you can implement a RadGrid control with GridTemplateColumn. In the column you can add a hyperlink that will be the url or even more each item will be a link where the Text is set as the Name of the item and NavigateUrl is set as the ContentItem.UrlWithExtenssion. You cannot pass the content item directly to the EventsView because we do not know the exact page where the EventsView resireds. So that we should use String.Concat and build the url. If you decide the use the url you can easily get it form ItemDataBound event of RadGrid control ( Guid itemID = new Guid(cnt.ID.ToString());)

    Below is a sample control that you can extend depending on your needs.

    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false"
    <MasterTableView> 
    <Columns> 
     <telerik:GridBoundColumn 
           DataField="Name" 
           HeaderText="Title" 
           UniqueName="Title" /> 
     <telerik:GridTemplateColumn> 
     <ItemTemplate> 
     <asp:HyperLink ID="Link1" runat="server" /> 
     </ItemTemplate> 
     </telerik:GridTemplateColumn> 
    </Columns> 
    </MasterTableView> 
    </telerik:RadGrid> 

    code behind:

     protected void Page_Load(object sender, EventArgs e) 
        { 
            RadGrid1.ItemDataBound += new Telerik.Web.UI.GridItemEventHandler(RadGrid1_ItemDataBound); 
            if (!Page.IsPostBack) 
            { 
                EventsManager manager = new EventsManager("Events"); 
                IList allEvents = manager.GetContent(); 
                RadGrid1.DataSource = allEvents; 
                RadGrid1.DataBind(); 
               
            } 
        } 
     
        void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
        { 
           if ((e.Item.ItemType == GridItemType.Item) || (e.Item.ItemType == GridItemType.AlternatingItem)) 
           { 
               IContent cnt = (IContent)e.Item.DataItem; 
               // get the id 
               //Guid itemID = new Guid(cnt.ID.ToString()); 
               HyperLink link = (HyperLink)e.Item.FindControl("Link1"); 
               link.NavigateUrl = cnt.UrlWithExtension.ToString(); 
               link.ToolTip = cnt.UrlWithExtension.ToString(); 
               link.Text = cnt.UrlWithExtension.ToString(); 
           } 
        } 

    I hope this helps.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Nigel
    Nigel avatar
    49 posts
    Registered:
    07 Jul 2008
    25 Aug 2009
    Link to this post
    Hi, thanks for the help, that should help if I go that way, which I was thinking would be a reasonable compromise, however is it possible to achieve it on the same page. Below is my template
    <telerik:RadDatePicker ID="StartDate" runat="server"></telerik:RadDatePicker> 
    <telerik:RadDatePicker ID="EndDate" runat="server"></telerik:RadDatePicker> 
    <telerik:RadTabStrip ID="DisplayModeTabStrip" runat="server">  
        <Tabs> 
            <telerik:RadTab Text="Listing" Value="List" runat="server"></telerik:RadTab> 
            <telerik:RadTab Text="Schedule" Value="Schedule" runat="server"></telerik:RadTab> 
            <telerik:RadTab Text="Details" Value="Details" Visible="false" runat="server"></telerik:RadTab> 
        </Tabs> 
    </telerik:RadTabStrip> 
    <telerik:RadMultiPage ID="DisplayModeMPage" runat="server">  
    <telerik:RadPageView ID="PageViewListing" runat="server">  
        <telerik:RadGrid ID="EventListing" runat="server"></telerik:RadGrid> 
    </telerik:RadPageView> 
    <telerik:RadPageView ID="PageViewSchedule" runat="server">  
        <sfEvents:EventsScheduleView ID="ScheduleView" runat="server"></sfEvents:EventsScheduleView> 
    </telerik:RadPageView> 
    <telerik:RadPageView ID="PageViewDetails" runat="server">  
        <sfEvents:EventsView ID="EventDetails" runat="server"></sfEvents:EventsView> 
    </telerik:RadPageView> 
    </telerik:RadMultiPage> 
    As you can see I am hoping to use a tabstrip to display the events in list or schedule view, and the display the details in a third tab when an event is selected. Can you see any way to make this work?

    Thanks for you help so far
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    26 Aug 2009
    Link to this post
    Hi Nigel,

    You need to modify the control template because there are associations between RadTabStrip and MultyPageView control.

    Below is a sample code

    <telerik:RadDatePicker ID="StartDate" runat="server"></telerik:RadDatePicker>  
    <telerik:RadDatePicker ID="EndDate" runat="server"></telerik:RadDatePicker>  
    <telerik:RadTabStrip ID="DisplayModeTabStrip" runat="server" MultiPageID="DisplayModeMPage">   
        <Tabs>  
            <telerik:RadTab Text="Listing" Value="List" runat="server"></telerik:RadTab>  
            <telerik:RadTab Text="Schedule" Value="Schedule" runat="server" PageViewID="ScheduleID"></telerik:RadTab>  
            <telerik:RadTab Text="Details" Value="Details" Visible="true" runat="server" PageViewID="DetailsID"></telerik:RadTab>  
        </Tabs>  
    </telerik:RadTabStrip>  
    <telerik:RadMultiPage ID="DisplayModeMPage" runat="server">   
    <telerik:RadPageView ID="PageViewListing" runat="server">   
      <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false"
    <MasterTableView> 
    <Columns> 
     <telerik:GridBoundColumn 
           DataField="Title" 
           HeaderText="Title" 
           UniqueName="Title" /> 
     <telerik:GridTemplateColumn> 
     <ItemTemplate> 
     <asp:HyperLink ID="Link1" runat="server" /> 
     </ItemTemplate> 
     </telerik:GridTemplateColumn> 
    </Columns> 
    </MasterTableView> 
    </telerik:RadGrid> 
     
    </telerik:RadPageView>  
    <telerik:RadPageView ID="PageViewSchedule" runat="server">   
        <sfEvents:EventsScheduleView ID="ScheduleView" runat="server"></sfEvents:EventsScheduleView>  
    </telerik:RadPageView>  
    <telerik:RadPageView ID="DetailsID" runat="server">   
        <sfEvents:EventsView ID="EventDetails" runat="server" ProviderName="Events" Enabled="true" DisplayMode="SingleItem"></sfEvents:EventsView>  
    </telerik:RadPageView>  
    </telerik:RadMultiPage>  

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using Telerik.Web.UI; 
    using Telerik.Cms.Engine; 
    using Telerik.Events; 
    using System.Collections; 
     
    public partial class CustomControls_EventsViewGrid : System.Web.UI.UserControl 
        protected void Page_Load(object sender, EventArgs e) 
        { 
          .... 
             .... 
     
          // here we bound the grid in the previous post. 
        } 
     
        void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
        { 
           if ((e.Item.ItemType == GridItemType.Item) || (e.Item.ItemType == GridItemType.AlternatingItem)) 
           { 
               IContent cnt = (IContent)e.Item.DataItem; 
               // get the id 
               //Guid itemID = new Guid(cnt.ID.ToString()); 
               HyperLink link = (HyperLink)e.Item.FindControl("Link1"); 
               link.NavigateUrl = String.Concat("/emptyproject/eventswithgrid" + cnt.UrlWithExtension.ToString()); 
               link.ToolTip = cnt.UrlWithExtension.ToString(); 
               link.Text = cnt.UrlWithExtension.ToString(); 
               DisplayModeMPage.SelectedIndex = 2; 
               DisplayModeTabStrip.SelectedIndex = 2; 
           } 
        } 


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
4 posts, 0 answered