Filtering the EVENTS Module
We just bought this CMS software. I am pretty new to the API. I have gone thru some documentation on the wesbite searching for my answers. Well i am still searching!!!. My question is regarding filtering by Category, Tags, start Date and End Date in the Events Module.
I am using Sitefinity 5.1
For example I have created Three Events. (Event1, Event2, Event3)
Event1 has a Category as CityA and Tags as Kids, Teens.
Event2 has a Category as CityB and Tags as Kids, Adults.
Event3 has a Category as CityC, and Tags as Teens, Adults.
I want filter the results based upon categories, tags and dates selected.
So i created 2 RadListBox with check boxes of Tags and Categories, and two RadDatePicker for the dates.
So how do i show all the Events based upon different Categories and Tags with start date and End Date ? The user can select Multiple Categories and multiple Tags. I want the result set to bind to a RadListView
I have made the ASCX page with the controls. I also tried to use the IMetaSearchInfo which is not working. I don't know what namespaces i need.
I also hard coded the Tags and Categories in the RadListBox with check boxes.
IS there any other way that i can automatically populate the RadListBox using the API without hard coding the tags and categories?
Here is MY ASCX Code
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Events.ascx.cs" Inherits="SitefinityWebApp.UserControls.Events" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
<telerik:RadSkinManager ID="QsfSkinManager" runat="server" ShowChooser="true" />
<telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All"
EnableRoundedCorners="false" />
<label for="NamesDDL">
Select contact name to view its product orders:</label>
<div style="margin-top: 15px;">
<table>
<tr>
<td>
Categories
</td>
<td>
Location
</td>
<td>
Start Date
</td>
<td>
End Date
</td>
</tr>
<tr>
<td>
<telerik:RadListBox ID="RadListBox1" runat="server" CheckBoxes="true" Width="120px"
Height="100px">
<Items>
<telerik:RadListBoxItem Text="Kids"></telerik:RadListBoxItem>
<telerik:RadListBoxItem Text="Adult"></telerik:RadListBoxItem>
<telerik:RadListBoxItem Text="Teens"></telerik:RadListBoxItem>
</Items>
</telerik:RadListBox>
</td>
<td>
<telerik:RadListBox ID="RadListBox2" runat="server" CheckBoxes="true" Height="100" Width="120px">
<Items>
<telerik:RadListBoxItem Text="CityA"></telerik:RadListBoxItem>
<telerik:RadListBoxItem Text="CityB"></telerik:RadListBoxItem>
<telerik:RadListBoxItem Text="CittyC"></telerik:RadListBoxItem>
</Items>
</telerik:RadListBox>
</td>
<td>
<telerik:RadDatePicker ID="RadDatePicker1" runat="server">
<Calendar ID="Calendar1" runat="server" EnableKeyboardNavigation="true">
</Calendar>
<DateInput ID="DateInput2" ToolTip="Date input" runat="server">
</DateInput>
</telerik:RadDatePicker>
</td>
<td>
<telerik:RadDatePicker ID="RadDatePicker2" runat="server">
<Calendar ID="Calendar2" runat="server" EnableKeyboardNavigation="true">
</Calendar>
<DateInput ID="DateInput1" ToolTip="Date input" runat="server">
</DateInput>
</telerik:RadDatePicker>
<telerik:RadButton ID="Submit" runat="server" Text="Search" OnClick="Submit_Click">
</telerik:RadButton>
</td>
</tr>
</table>
</div>
<div style="margin: 15px 0 20px;">
<telerik:RadListView ID="RadListView1" DataSourceID="SqlDataSource1" runat="server"
ItemPlaceholderID="EmployeesContainer" AllowPaging="True" PageSize=3>
<LayoutTemplate>
<fieldset style="width: 900px">
<legend>Events</legend>
<asp:PlaceHolder ID="EmployeesContainer" runat="server"></asp:PlaceHolder>
</fieldset>
</LayoutTemplate>
<ItemTemplate>
<fieldset style="float: left; width: 420px;">
<legend>Company:
<%#Eval("Title")%>
</legend>
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<table cellpadding="0" cellspacing="0">
<tr>
<td style="width: 25%">Location:
</td>
<td style="width: 50%">
<%#Eval("Location")%>
</td>
</tr>
<tr>
<td>Address:
</td>
<td>
<%#Eval("Address")%>
</td>
</tr>
<tr>
<td>Contact:
</td>
<td>
<%# Eval("Contact")%>
</td>
</tr>
<tr>
<td>Email:
</td>
<td>
<%# Eval("Email")%>
</td>
</tr>
<tr>
<td>Website:
</td>
<td>
<%# Eval("Website")%>
</td>
</tr>
<tr>
<td>Phone:
</td>
<td>
<%#Eval("Phone")%>
</td>
</tr>
</table>
</td>
<td align="right" style="width: 25%; padding-left: 10px;">
<telerik:RadBinaryImage ID="RadBinaryImage1" runat="server" AlternateText="Contact Photo"
ToolTip="Contact Photo" Width="90px" Height="110px" ResizeMode="Fit" DataValue='<%# Eval("Photo") %>'>
</telerik:RadBinaryImage>
</td>
</tr>
</table>
</fieldset>
</ItemTemplate>
<AlternatingItemTemplate>
<fieldset style="float: left; width: 420px;">
<legend>Company:
<%#Eval("CompanyName")%>
</legend>
<table cellpadding="0" cellspacing="0">
<tr>
<td style="width: 25%">Location:
</td>
<td style="width: 50%">
<%#Eval("Location")%>
</td>
</tr>
<tr>
<td>Address:
</td>
<td>
<%#Eval("Address")%>
</td>
</tr>
<tr>
<td>Contact:
</td>
<td>
<%# Eval("Contact")%>
</td>
</tr>
<tr>
<td>Email:
</td>
<td>
<%# Eval("Email")%>
</td>
</tr>
<tr>
<td>Website:
</td>
<td>
<%# Eval("Website")%>
</td>
</tr>
<tr>
<td>Phone:
</td>
<td>
<%#Eval("Phone")%>
</td>
</tr>
</table>
</td>
<td align="right" style="width: 25%; padding-left: 10px;">
<telerik:RadBinaryImage ID="RadBinaryImage1" runat="server" AlternateText="Contact Photo"
ToolTip="Contact Photo" Width="90px" Height="110px" ResizeMode="Fit" DataValue='<%# Eval("Photo") %>'>
</telerik:RadBinaryImage>
</td>
</tr>
</table>
</fieldset>
</AlternatingItemTemplate>
</telerik:RadListView>
</div>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableAJAX="true" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="NamesDDL">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="EventsGrid" LoadingPanelID="AjaxLoadingPanel1">
</telerik:AjaxUpdatedControl>
<telerik:AjaxUpdatedControl ControlID="NamesDDL"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
</telerik:RadAjaxLoadingPanel>
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Here is my Code Behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Sitefinity;
using Telerik.Sitefinity.GenericContent.Model;
using Telerik.Web.UI;
using System.ComponentModel;
using Telerik.Sitefinity.Web.DataResolving;
using Telerik.Sitefinity.Pages.Model;
using Telerik.Sitefinity.Events.Model;
using Telerik.Sitefinity.Modules.Events;
using Telerik.Sitefinity.Model;
using Telerik.Sitefinity.Workflow;
using System.Collections;
using System.Text;
using Telerik.OpenAccess;
namespace SitefinityWebApp.UserControls
public partial class Events : System.Web.UI.UserControl
protected void Page_Load(object sender, EventArgs e)
protected void Submit_Click(object sender, EventArgs e)
StringBuilder sb = new StringBuilder();
IList<RadListBoxItem> collection = RadListBox1.CheckedItems;
foreach (RadListBoxItem item in collection)
sb.Append(item.Value + ",");
String Catg;
Catg = sb.ToString();
StringBuilder sbTag = new StringBuilder();
IList<RadListBoxItem> collectionTag = RadListBox1.CheckedItems;
foreach (RadListBoxItem item in collectionTag)
sbTag.Append(item.Value + ",");
String Tags;
Tags = sbTag.ToString();
// new instance of eventsManager
EventsManager eventsManager = new EventsManager("Events");
//create a filer
List<IMetaSearchInfo> filter = new List<IMetaSearchInfo>();
filter.Add(new MetaSearchInfo(MetaValueTypes.ShortText, "Category", Catg, SearchCondition.Equal, JoinType.And));
filter.Add(new MetaSearchInfo(MetaValueTypes.ShortText, "Tags", Tags, SearchCondition.Equal, JoinType.And));
filter.Add(new MetaSearchInfo(MetaValueTypes.ShortText, "Event_Start", RadDatePicker1.SelectedDate.Value.ToShortDateString(), SearchCondition.Equal, JoinType.And));
filter.Add(new MetaSearchInfo(MetaValueTypes.ShortText, "Event_End", RadDatePicker2.SelectedDate.Value.ToShortDateString(), SearchCondition.Equal, JoinType.And));
// get all events
IList listOfAllEvents = eventsManager.Content.GetContent(0, 0, string.Empty, null, string.Empty, null, filter.ToArray());
// foreach (IContent eventItem in listOfAllEvents)
// Response.Write(eventItem.GetMetaData("Title").ToString() + "<br />");
RadListView1.DataSource = listOfAllEvents.ToString();
RadListView1.DataBind();
// filterBuilder.AddFilter(new ContentFilterStatement("Tag.Name", tag.TagName, ContentFilter.Condition.Equal, ContentFilter.JoinType.And));
Hello Rajeev,
First off, I'd like to refer you to Sitefinity's Developer's Guide. There you may find many references on how to use Sitefinity's components, managers, providers and content items (see some links I've included in the answer below).
For example, here is an article which shows how to correctly use EventsManager in order to retrieve events, and here is the documentation page about Events.
If you build your page/control with some powerful code-behind you may be get more flexibility and power, for example you may want to use Sitefinity's convenient, yet powerful, Fluent API.
To help you with your current attempt, I've produced an alternative to your code (it in a regular webform .aspx. You could, of course, wrap the code as a user-control, add it to the regular page's toolbox and then simply drag and drop it directly on a page with Sitefinity's page editor).
Here is the apsx client site markup, and some comments below it:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="EventsPage1.aspx.cs" Inherits="SitefinityWebApp.EventsPage" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<!DOCTYPE html>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
runat
=
"server"
ID
=
"RadScriptManager1"
/>
<
table
>
<
tr
>
<
td
>
Categories
</
td
>
<
td
>
Location
</
td
>
<
td
>
Start Date
</
td
>
<
td
>
End Date
</
td
>
</
tr
>
<
tr
>
<
td
>
<
asp:DropDownList
ID
=
"categorySelector"
runat
=
"server"
/>
</
td
>
<
td
>
<
asp:DropDownList
ID
=
"citySelector"
runat
=
"server"
/>
</
td
>
<
td
>
<
telerik:RadDatePicker
ID
=
"RadDatePicker1"
runat
=
"server"
>
<
Calendar
ID
=
"Calendar1"
runat
=
"server"
EnableKeyboardNavigation
=
"true"
>
</
Calendar
>
<
DateInput
ID
=
"DateInput2"
ToolTip
=
"Date input"
runat
=
"server"
>
</
DateInput
>
</
telerik:RadDatePicker
>
</
td
>
<
td
>
<
telerik:RadDatePicker
ID
=
"RadDatePicker2"
runat
=
"server"
>
<
Calendar
ID
=
"Calendar2"
runat
=
"server"
EnableKeyboardNavigation
=
"true"
/>
<
DateInput
ID
=
"DateInput1"
ToolTip
=
"Date input"
runat
=
"server"
/>
</
telerik:RadDatePicker
>
<
telerik:RadButton
ID
=
"Submit"
runat
=
"server"
Text
=
"Search"
/>
</
td
>
</
tr
>
</
table
>
<
telerik:RadListView
ID
=
"RadListView1"
runat
=
"server"
AllowPaging
=
"True"
PageSize
=
3
ItemPlaceholderID
=
"EmployeesContainer"
>
<
LayoutTemplate
>
<
fieldset
style
=
"width: 900px"
>
<
legend
>Events</
legend
>
<
asp:PlaceHolder
ID
=
"EmployeesContainer"
runat
=
"server"
/>
</
fieldset
>
</
LayoutTemplate
>
<
ItemTemplate
>
<
fieldset
style
=
"float: left; width: 420px;"
>
<
legend
>Company:
<%#Eval("Title")%>
</
legend
>
<
table
cellpadding
=
"0"
cellspacing
=
"0"
>
<
tr
>
<
td
>
<
table
cellpadding
=
"0"
cellspacing
=
"0"
>
<
tr
>
<
td
style
=
"width: 25%"
>Location:
</
td
>
<
td
style
=
"width: 50%"
>
<%#Eval("City")%>
</
td
>
</
tr
>
<
tr
>
<
td
>Address:
</
td
>
<
td
>
<%#Eval("Street")%>
</
td
>
</
tr
>
<
tr
>
<
td
>Contact:
</
td
>
<
td
>
<%# Eval("ContactName")%>
</
td
>
</
tr
>
<
tr
>
<
td
>Email:
</
td
>
<
td
>
<%# Eval("ContactEmail")%>
</
td
>
</
tr
>
<
tr
>
<
td
>Website:
</
td
>
<
td
>
<%# Eval("ContactWeb")%>
</
td
>
</
tr
>
<
tr
>
<
td
>Phone:
</
td
>
<
td
>
<%#Eval("ContactPhone")%>
</
td
>
</
tr
>
</
table
>
</
td
>
</
tr
>
</
table
>
</
fieldset
>
</
ItemTemplate
>
</
telerik:RadListView
>
</
form
>
</
body
>
</
html
>
My server side code-behind:
using
System;
using
System.Linq;
using
Telerik.Sitefinity.Events.Model;
using
Telerik.Sitefinity.GenericContent.Model;
using
Telerik.Sitefinity.Modules.Events;
using
Telerik.Sitefinity.Taxonomies;
namespace
SitefinityWebApp
public
partial
class
EventsPage : System.Web.UI.Page
protected
void
Page_Load(
object
sender, EventArgs e)
if
(!IsPostBack)
TaxonomyManager taxMan = TaxonomyManager.GetManager();
var categories = taxMan.GetTaxonomy(TaxonomyManager.CategoriesTaxonomyId).Taxa;
categorySelector.DataValueField =
"Id"
;
categorySelector.DataTextField =
"Title"
;
categorySelector.DataSource = categories;
categorySelector.DataBind();
EventsManager eventsMan = EventsManager.GetManager();
var cities = eventsMan.GetEvents().Select(evt => evt.City.ToString()).ToList().Distinct();
citySelector.DataSource = cities;
citySelector.DataBind();
Submit.Click += Submit_Click;
void
Submit_Click(
object
sender, EventArgs e)
EventsManager eventsMan = EventsManager.GetManager();
int
? totalcount = -1;
var categoryId = categorySelector.Items[categorySelector.SelectedIndex].Value;
string
city = citySelector.Items[citySelector.SelectedIndex].Value;
IQueryable<Event> events =
null
;
if
(!categoryId.IsNullOrWhitespace())
events = eventsMan.Provider.GetItemsByTaxon(
new
Guid(categoryId),
false
,
"Category"
,
typeof
(Event),
"Status = Master"
,
""
,
RadListView1.PageSize * RadListView1.CurrentPageIndex,
RadListView1.PageSize,
ref
totalcount).Cast<Event>().AsQueryable();
else
events = eventsMan.GetEvents()
.Where(evt => evt.Status == ContentLifecycleStatus.Master)
.Skip(RadListView1.PageSize * RadListView1.CurrentPageIndex)
.Take(RadListView1.PageSize);
if
(!city.IsNullOrWhitespace())
events = events.Where(evt => evt.City == city);
if
(RadDatePicker1.SelectedDate !=
null
)
events = events.Where(evt => evt.EventStart >= RadDatePicker1.SelectedDate);
if
(RadDatePicker2.SelectedDate !=
null
)
events = events.Where(evt => evt.EventStart <= RadDatePicker2.SelectedDate);
RadListView1.DataSource = events;
RadListView1.DataBind();
I hope you find this information helpful in order to progress with your development.
Thanks for your help. I am kind of stuck on Two things. I did some
changes to the previous code.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Events.ascx.cs" Inherits="SitefinityWebApp.UserControls.Events" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<
head
>
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function pageLoad(sender, args)
var productsTable = $get("products");
var firstRow;
if (productsTable.tBodies)
firstRow = productsTable.tBodies[0].rows[0];
else
firstRow = productsTable.rows[0];
var expandImg = firstRow.cells[0].getElementsByTagName("IMG")[0];
if (expandImg.src.indexOf("Plus") > -1)
toggleOrderDetails(expandImg);
function toggleOrderDetails(sender)
var thisRow = sender.parentNode.parentNode;
var nextRow = getNextRowSibling(thisRow);
if (nextRow && nextRow.className == "orders")
if (nextRow.style.display == "none")
nextRow.style.display = "";
sender.src = sender.src.replace("Plus", "Minus");
thisRow.className = "expanded";
else
nextRow.style.display = "none";
sender.src = sender.src.replace("Minus", "Plus");
thisRow.className = "";
function getNextRowSibling(row)
var ret = row;
do
ret = ret.nextSibling;
while (ret && ret.tagName != "TR");
return ret;
</
script
>
</
telerik:RadCodeBlock
>
<
style
type
=
"text/css"
>
.wrapper
width: 608px;
border: 1px solid #5D8CC9;
font-family: "segoe ui" ,arial,sans-serif;
font-size: 12px;
line-height: 16px;
.products
empty-cells: show;
table-layout: fixed;
border-collapse: collapse;
width: 100%;
.products th
background-color: #C3D8F1;
padding: 5px;
border-bottom: 1px solid #5D8CC9;
color: #00156E;
text-align: left;
width: 130px;
.products td
border: 1px solid #D0D7E5;
border-style: none none solid none;
padding: 4px 7px 3px 7px;
.products th.expand, .products td.expand
width: 20px;
padding: 0 0 0 3px;
.products tr td.expand
border-color: #ECF4FF;
.products tr.expanded td, .orders td.expand
background-color: #ECF4FF;
.products tr td.expand img
cursor: pointer;
.orders td
padding: 0;
width: auto;
.orders table
table-layout: fixed;
border-collapse: collapse;
width: 100%;
.orders table td
width: 130px;
padding: 4px 7px 3px 7px;
padding: 3px 3px 3px 7px;
.orders table tr:last-child td
border-bottom: none;
</
style
>
</
head
>
<
body
>
<
telerik:RadScriptManager
runat
=
"server"
ID
=
"RadScriptManager1"
/>
<
telerik:RadFormDecorator
ID
=
"QsfFromDecorator"
runat
=
"server"
DecoratedControls
=
"All"
EnableRoundedCorners
=
"false"
/>
<
div
style
=
"width: 610px;"
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"SushiPanel"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"SushiPanel"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
>
</
telerik:AjaxUpdatedControl
>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
Skin
=
"Black"
>
</
telerik:RadAjaxLoadingPanel
>
<
div
>
<
table
>
<
tr
>
<
td
>
Location
</
td
>
<
td
>
Event Type
</
td
>
<
td
>
Start Date
</
td
>
<
td
>
End Date
</
td
>
</
tr
>
<
tr
>
<
td
>
<
telerik:RadListBox
ID
=
"citySelector"
runat
=
"server"
>
</
telerik:RadListBox
>
</
td
>
<
td
>
<
telerik:RadListBox
ID
=
"tagSelector"
runat
=
"server"
>
</
telerik:RadListBox
>
</
td
>
<
td
>
<
telerik:RadDatePicker
ID
=
"RadDatePicker1"
runat
=
"server"
>
<
Calendar
ID
=
"Calendar1"
runat
=
"server"
EnableKeyboardNavigation
=
"true"
>
</
Calendar
>
<
DateInput
ID
=
"DateInput2"
ToolTip
=
"Date input"
runat
=
"server"
>
</
DateInput
>
</
telerik:RadDatePicker
>
</
td
>
<
td
>
<
telerik:RadDatePicker
ID
=
"RadDatePicker2"
runat
=
"server"
>
<
Calendar
ID
=
"Calendar2"
runat
=
"server"
EnableKeyboardNavigation
=
"true"
/>
<
DateInput
ID
=
"DateInput1"
ToolTip
=
"Date input"
runat
=
"server"
/>
</
telerik:RadDatePicker
>
<
telerik:RadButton
ID
=
"Submit"
runat
=
"server"
Text
=
"Search"
OnClick
=
"Submit_Click"
/>
</
td
>
</
tr
>
</
table
>
<
br
/>
<
br
/>
<
br
/>
<
telerik:RadListView
ID
=
"RadListView1"
runat
=
"server"
ItemPlaceholderID
=
"ProductTitlePlaceHolder"
AllowPaging
=
"True"
>
<
LayoutTemplate
>
<
fieldset
style
=
"width: 900px"
>
<
legend
>Events</
legend
>
<
asp:PlaceHolder
ID
=
"EmployeesContainer"
runat
=
"server"
/>
</
fieldset
>
<
asp:Panel
ID
=
"HierarchyPanel"
runat
=
"server"
CssClass
=
"wrapper"
>
<
table
id
=
"products"
class
=
"products"
>
<
thead
>
<
tr
>
</
tr
>
</
thead
>
<
tbody
>
<
tr
id
=
"ProductTitlePlaceHolder"
runat
=
"server"
>
</
tr
>
</
tbody
>
</
table
>
</
asp:Panel
>
<
table
cellpadding
=
"0"
cellspacing
=
"0"
width
=
"100%;"
style
=
"clear: both;"
>
<
tr
>
<
td
>
<
telerik:RadDataPager
ID
=
"RadDataPager1"
runat
=
"server"
PagedControlID
=
"RadListView1"
OnPreRender
=
"Pager_Pre"
PageSize
=
"2"
Visible='<%# Container.PageCount != 1%>'>
<
Fields
>
<
telerik:RadDataPagerButtonField
FieldType
=
"FirstPrev"
/>
<
telerik:RadDataPagerButtonField
FieldType
=
"Numeric"
PageButtonCount
=
"5"
/>
<
telerik:RadDataPagerButtonField
FieldType
=
"NextLast"
/>
<
telerik:RadDataPagerTemplatePageField
>
<
PagerTemplate
>
<
div
style
=
"float: right"
>
<
b
>Items
<
asp:Label
runat
=
"server"
ID
=
"CurrentPageLabel"
Text="<%# Container.Owner.StartRowIndex+1%>" />
to
<
asp:Label
runat
=
"server"
ID
=
"TotalPagesLabel"
Text="<%# Container.Owner.TotalRowCount > (Container.Owner.StartRowIndex+Container.Owner.PageSize) ? Container.Owner.StartRowIndex+Container.Owner.PageSize : Container.Owner.TotalRowCount %>" />
of
<
asp:Label
runat
=
"server"
ID
=
"TotalItemsLabel"
Text="<%# Container.Owner.TotalRowCount%>" />
<
br
/>
</
b
>
</
div
>
</
PagerTemplate
>
</
telerik:RadDataPagerTemplatePageField
>
</
Fields
>
</
telerik:RadDataPager
><
br
/><
br
/>
</
td
>
</
tr
>
</
table
>
</
LayoutTemplate
>
<
ItemTemplate
>
<
tr
>
<
td
class
=
"expand"
>
<
img
src
=
"../Images/Default%20Images/SinglePlus.gif"
alt
=
"Plus"
onclick
=
"toggleOrderDetails(this)"
/>
</
td
>
<
td
colspan
=
"4"
>
<
b
>Title:</
b
> <
asp:Label
ID
=
"TitleLabel"
runat
=
"server"
Text='<%# Eval("Title") %>' /><
br
/>
<
br
/>
</
td
>
</
tr
>
<
tr
class
=
"orders"
style
=
"display: none;"
>
<
td
class
=
"expand"
>
</
td
>
<
td
colspan
=
"4"
>
<
telerik:RadListView
ID
=
"RadListView2"
runat
=
"server"
ItemPlaceholderID
=
"OrderDetailsPlaceHolder"
EnableViewState
=
"false"
>
<
LayoutTemplate
>
<
table
>
<
asp:PlaceHolder
ID
=
"OrderDetailsPlaceHolder"
runat
=
"server"
></
asp:PlaceHolder
>
</
table
>
</
LayoutTemplate
>
<
ItemTemplate
>
<
tr
>
<
td
>
<
b
>Date Start:</
b
>
<%#Eval("EventStart")%>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
b
>Date End</
b
>
<%#Eval("EventEnd")%>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
b
>Street</
b
>
<%#Eval("Street")%>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
b
>City:</
b
>
<%# Eval("City") %>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
b
>State</
b
>
<%#Eval("State")%>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
b
>Country:</
b
>
<%# Eval("Country") %>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
b
>Summary</
b
>
<%#Eval("Summary")%>
</
td
>
</
tr
>
</
ItemTemplate
>
</
telerik:RadListView
>
</
td
>
</
tr
>
</
ItemTemplate
>
</
telerik:RadListView
>
</
div
>
</
div
>
</
body
>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Sitefinity.Events.Model;
using Telerik.Sitefinity.GenericContent.Model;
using Telerik.Sitefinity.Modules.Events;
using Telerik.Sitefinity.Taxonomies;
using Telerik.Web.UI;
namespace SitefinityWebApp.UserControls
public partial class Events : System.Web.UI.UserControl
protected void Page_Load(object sender, EventArgs e)
protected void Pager_Pre(object sender, System.EventArgs e)
// RadListView1.DataSource = Session["Event"];
// RadListView1.DataBind();
protected void Page_Init(object sender, System.EventArgs e)
LoadData();
protected void LoadData()
TaxonomyManager taxMan = TaxonomyManager.GetManager();
var tags = taxMan.GetTaxonomy(TaxonomyManager.TagsTaxonomyId).Taxa;
tagSelector.DataTextField = "Title";
tagSelector.DataValueField = "Id";
tagSelector.DataSource = tags;
tagSelector.DataBind();
EventsManager eventsMan = EventsManager.GetManager();
var cities = eventsMan.GetEvents().Select(evt => evt.City.ToString()).ToList().Distinct();
citySelector.DataSource = cities;
citySelector.DataBind();
protected void Submit_Click(object sender, EventArgs e)
EventsManager eventsMan = EventsManager.GetManager();
string tagId;
if (tagSelector.SelectedIndex == -1)
tagId = "";
else
tagId = tagSelector.SelectedValue;
string city;
if (citySelector.SelectedIndex == -1)
city = "";
else
city = citySelector.SelectedItem.Text;
int? totalCount = -1;
IQueryable<
Event
> events = null;
if (!tagId.IsNullOrWhitespace())
events = eventsMan.Provider.GetItemsByTaxon(
new Guid(tagId),
false,
"Tags",
typeof(Event),
"Status = Master", "",
0, 100, ref totalCount).Cast<
Event
>().AsQueryable();
// RadListView1.PageSize * RadListView1.CurrentPageIndex,
// RadListView1.PageSize, ref totalCount).Cast<
Event
>().AsQueryable();
else
events = eventsMan.GetEvents()
.Where(evt => evt.Status == ContentLifecycleStatus.Master)
// .Skip(RadListView1.PageSize * RadListView1.CurrentPageIndex)
// .Take(RadListView1.PageSize);
.Skip(0)
.Take(100);
if (!city.IsNullOrWhitespace())
events = events.Where(evt => evt.City == city);
if (RadDatePicker1.SelectedDate != null)
events = events.Where(evt => evt.EventStart >= RadDatePicker1.SelectedDate);
if (RadDatePicker2.SelectedDate != null)
events = events.Where(evt => evt.EventStart <= RadDatePicker2.SelectedDate);
RadListView1.DataSource = events;
RadListView1.DataBind();
LoadData();
foreach (RadListViewDataItem item in RadListView1.Items)
Label TitleLabel = (Label)item.FindControl("TitleLabel");
RadListView lb = (RadListView)item.FindControl("RadListView2");
string test = TitleLabel.Text;
IQueryable<
Event
> Subevents = null;
Subevents = eventsMan.GetEvents().Where(evt => (evt.Title == test && evt.Status == ContentLifecycleStatus.Live));
lb.DataSource = Subevents;
lb.DataBind();
//
Hi Rajeev,
Maybe you already tried this, but be sure to turn on the ViewState option inside the page properties where you host your UserControl.
I think that you need it in order to preserve the viewstate with the values of the selected listitems.
Regards,
Daniel
It is still not working