Beginner Question on Creating RadRotator
I have begun developing on Sitefinity for an update to my company website. I am learning at the moment and am attempting to create a RadRotator based control for our home page. I have created a RadRotator using an XML file for a data source to learn that control. I have also created a custom module: TestFrontPageItem with 'Title', Summary, and ImageSource as fields. I am stumped on how to pass the fields from my module to the RadRotator control.
Following a tutorial in the Getting started, I have created a Test.ascx user control and I was able to get data to show up on my page by copying the code generated in the custom module:
<
telerik:radgrid
id
=
"Grid"
runat
=
"server"
autogeneratecolumns
=
"True"
>
<
mastertableview
>
<
columns
>
<
telerik:gridboundcolumn
datafield
=
"Title"
headertext
=
"Title"
></
telerik:gridboundcolumn
>
</
columns
>
</
mastertableview
>
</
telerik:radgrid
>
protected
void
Page_Load(
object
sender, EventArgs e)
var myCollection = GetDataItems();
// Binds the collection of Person items to the RadGrid
Grid.DataSource = myCollection;
Grid.DataBind();
public
IQueryable<DynamicContent> GetDataItems()
DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
Type testfrontpageitemType = TypeResolutionService.ResolveType(
"Telerik.Sitefinity.DynamicTypes.Model.TestFrontPageItem.Testfrontpageitem"
);
// Fetch a collection of "live" and "visible" testfrontpageitem items.
var myCollection = dynamicModuleManager.GetDataItems(testfrontpageitemType)
.Where(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && i.Visible ==
true
);
return
myCollection;
<
telerik:RadRotator
ID
=
"RadRotator1"
runat
=
"server"
RotatorType
=
"Carousel"
>
<
ItemTemplate
>
<
div
>
<
asp:Label
runat
=
"server"
ID
=
"Summary"
text="<%# Summary %>"/>
<
asp:Label
runat
=
"server"
ID
=
"Title"
Text="<%# Title %>"></
asp:Label
>
<
asp:Image
runat
=
"server"
ID
=
"ImageURL"
ImageUrl="<%# %>" "/>
</
div
>
</
ItemTemplate
>
</
telerik:RadRotator
>
The correct syntax on the binding statements.
here is what it should look like:
<%# Eval("Title") %>
so in full - Text='<%# Eval("Title") %>' Note the use of single quotes wrapping the full statement.
thank you for your help -- this did it -- I hadn't found the Eval() in any examples that I have looked at up to now.
Hello,
I would advise to take a look at our News Rotator control in the SDK which you can also try implementing yourself by following the instructions in the Documentation. You can also go through the RadRotator demos available here.
Regards,