IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
After you Locations module: Create the master list view, you create the details view. You use the details view to load the details for the items. To create the details view:
<%@ Control Language=
"C#"
%>
<%@ Register TagPrefix=
"sf"
Namespace=
"Telerik.Sitefinity.Web.UI.ContentUI"
Assembly=
"Telerik.Sitefinity"
"Telerik.Sitefinity.Web.UI"
"telerik"
"Telerik.Web.UI"
<div
class
=
"locations-single content"
>
<telerik:RadListView ID=
"DetailsView"
ItemPlaceholderID=
"ItemsContainer"
runat=
"server"
EnableEmbeddedSkins=
"false"
EnableEmbeddedBaseStylesheet=
<LayoutTemplate>
<asp:PlaceHolder ID=
/>
</LayoutTemplate>
<ItemTemplate>
"column-small"
"block"
<p id=
"photo"
></p>
<h1><sf:FieldListView ID=
"Title"
Text=
"{0}"
Properties=
/></h1>
<address>
<sf:FieldListView ID=
"Address"
/><br />
"City"
"Region"
"PostalCode"
</address>
<p><a href=
"<%= ResolveUrl(Telerik.Sitefinity.Web.SiteMapBase.GetActualCurrentNode().Url) %>"
>« All Locations</a></p>
</div>
</ItemTemplate>
</telerik:RadListView>
using
System.Web.UI;
LocationsModule.Model;
Telerik.Sitefinity.Web.UI;
Telerik.Sitefinity.Web.UI.ContentUI.Contracts;
Telerik.Sitefinity.Web.UI.ContentUI.Views.Backend;
Telerik.Sitefinity.Web.UI.Templates;
Telerik.Web.UI;
public
DetailsView : ViewBase
{
}
protected
override
string
LayoutTemplateName
get
return
null
; }
LayoutTemplatePath
var path =
"~/LocationTemplates/"
+ layoutTemplateName;
path;
set
base
.LayoutTemplatePath = value;
internal
const
layoutTemplateName =
"LocationsModule.Web.UI.Public.Resources.DetailsView.ascx"
;
virtual
RadListView DetailsViewControl
this
.Container.GetControl<RadListView>(
,
true
);
void
InitializeControls(GenericContainer container, IContentViewDefinition definition)
// ensure a valid definition is passed
var detailDefinition = definition
as
IContentViewDetailDefinition;
if
(detailDefinition ==
)
// retrieve item from host control
var locationsView = (LocationsView)
.Host;
var item = locationsView.DetailItem
LocationItem;
(item ==
// no item
(
.IsDesignMode())
.Controls.Clear();
.Controls.Add(
new
LiteralControl(
"A location item was not selected or has been deleted. Please select another one."
));
// show item details
.DetailsViewControl.DataSource =
LocationItem[] { item };
In the code snippets above, the details view is loaded by the Locations view to display details for published items. The details view inherits from ViewBase. In the markup, you first register the necessary assemblies, so that they can be used in the template. You then create a RadListView to display the details for the item.
In the DetailsView.cs, you reference the RadListView control from the DetailsView.ascx by calling GetControl. Finally you override the InitializeControls method to set the data source for the RadListView control.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important