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

2 posts, 0 answers
    HMPSOLBB avatar
    15 posts
    Member since:
    Mar 2012

    Posted 25 Jul Link to this post

    I found this post 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?







  2. Viktor Tachev
    Viktor Tachev avatar
    1445 posts

    Posted 28 Jul Link to this post

    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";
        ImageGalleryTemplateItem igti = new ImageGalleryTemplateItem();
        ImageGalleryContentTemplate template = new ImageGalleryContentTemplate();
        igti.ContentTemplate = template;

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

    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.
  3. DevCraft R3 2016 release webinar banner
Back to Top