+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Read from a different database

Read from a different database

7 posts, 0 answered
  1. Viren
    Viren avatar
    41 posts
    Registered:
    03 Aug 2010
    15 Oct 2010
    Link to this post
    Hi,

    Is it possible to make an image gallery control inside sitefinity pick images from a database other than sitefinity's own db? I will need a detailed guidance on this one if it is possible. Any help is much appreciated.

    Thanks
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    15 Oct 2010
    Link to this post
    Hi Viren,

    The control does not support external datasource as a public property. Generally you need a custom control or override most of the logic of the built-in control. The control expects certain objects that are specific with Sitefinity and overriding the control will be a lot of work. This is why I would suggest that you should create your own control.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Viren
    Viren avatar
    41 posts
    Registered:
    03 Aug 2010
    15 Oct 2010
    Link to this post
    Thanks for the reply. I got your point. However my underlying problem is to be able to use seperate custom Sitefinity templates for the thumbnails and the page. To be specific, I want to use the List & Page presentation mode of the image gallery. However I want to be able to use template1 that I created for displaying the thumbnails (list) and template2 for the page(actual image when clicked upon the thumbnail). I cannot find the .aspx file for imagegallery control under websiteroot > Sitefinity > UserControls so I cannot modify it in any way. The difference between template1 and 2 is that template2 has a little more styling and some Generic controls around it. I hope that my question is clear and I apologize if this has been answered elsewhere on the site.

    Also I get a hint from your reply that it is possible to make the image gallery control pull images from an external database. I would really appreciate if you could send me an example demonstrating how to achieve this as this would save us a lot of database replication and also would avoid network related issues.

    Thanks.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Oct 2010
    Link to this post
    Hi Viren,

    1. Image Gallery control uses external templates. All external templates are available under Downloads section of your account

    2. You can use Generic Content API to transfer your current database objects to IContent objects and use the Image Gallery control

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Viren
    Viren avatar
    41 posts
    Registered:
    03 Aug 2010
    21 Oct 2010
    Link to this post
    Thanks. In order to implement your point # 2, can I simply import the required assemblies and namespaces at the top of the GalleryListView.ascx file, and then include a c# type script that has a CreateDataSource() method and open a connection to my db in this method and also convert the images to IContent objects? Would this work?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    21 Oct 2010
    Link to this post
    Hi Viren,

    You can override CreateDataSource method of ImageGallery control and there move these content that makes connection to your database. Then create a class in App_Code or class library that you call inside CreateDataSource and return the IContent objects as a List or Generic List.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Viren
    Viren avatar
    41 posts
    Registered:
    03 Aug 2010
    21 Oct 2010
    Link to this post
    Do you have any sample for this for sitefinity 3.6 and higher wherein there is no code behind available for the templates? My database column contains images stored as binary data. Can I do something like this inside the GalleryViewList.ascx template file:

    <script type="text/C#">
    protected override IList ContentBasic.CreateDataSource()
    {
        //Open new db connection here
       // call my class under App_Code or can I do what this class does here?
       return ((IList)images)
    }
    </script>
    Can you please tell me if this is the right way to do it?

    Thanks.
Register for webinar
7 posts, 0 answered