This is a migrated thread and some comments may be shown as answers.

Add MediaPlayer in TemplateItem from code behind (images AND videos)

1 Answer 99 Views
ImageGallery
This is a migrated thread and some comments may be shown as answers.
HMPSOLBB
Top achievements
Rank 1
HMPSOLBB asked on 25 Jul 2016, 11:20 AM

I found this post http://www.telerik.com/forums/how-can-i-add-mediaplayer-in-templateitem-from-code-behind#LMcMKDN-1kyBzTiLR_Sa2A whitch works fine if iprvide only video files. Now i got a db with images and videos and try to put them together in a ImageGallery. is there a way to publish such a Gellery with a mixture of images and videos. For images i don´t need a template bit für the videos i will do so. All the data are providet by a datatable in code behind.

 

Anyone gots some hints for me?

 

regs

Oliver

 

 

 

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 28 Jul 2016, 07:31 AM
Hi Oliver,

You can add additional items to the RadImageGallery the same way as the template item.


class ImageGalleryContentTemplate : ITemplate
{
    public String BackgroundImage { get; set; }
    public String HTMLTemplate { get; set; }
 
 
    public void InstantiateIn(Control container)
    {
        container.Controls.Add(new RadMediaPlayer());
    }
}
 
protected void Page_Init(object sender, EventArgs e)
{
    ImageGalleryItem igItem = new ImageGalleryItem();
    igItem.ImageUrl = "~/Images/ImageGallery/image1.jpg";
    RIG.Items.Add(igItem);
 
    ImageGalleryTemplateItem igti = new ImageGalleryTemplateItem();
    ImageGalleryContentTemplate template = new ImageGalleryContentTemplate();
    igti.ContentTemplate = template;
    RIG.Items.Add(igti);
 
}


In your scenario you can iterate through the items of the DataTable and add the necessary items to the ImageGallery.


Regards,
Viktor Tachev
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
ImageGallery
Asked by
HMPSOLBB
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or