Binding Binary Image to RAD Image Gallery

12 posts, 1 answers
  1. Rahul
    Rahul avatar
    14 posts
    Member since:
    Feb 2013

    Posted 11 Aug 2014 Link to this post

    Hi,

    I am storing Image in Database in binary format. Is it possible to bind Rad Image gallery control to binary images?. Also I want to add this inside RAD Grid, I am binding Grid on NEED DATASOURCE event. please help me.



    Thank you.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Aug 2014 in reply to Rahul Link to this post

    Hi Rahul,

    Please take a look into the Programmatic Data Binding part of this online demo.

    Thanks,
    Princy.
  3. Rahul
    Rahul avatar
    14 posts
    Member since:
    Feb 2013

    Posted 12 Aug 2014 in reply to Princy Link to this post

    Hi Princy,

    Thank you for your quick responce.
    I saw that example but I am not storing image URL, I am storing an Image in binary format, so is it possible to bind binary data to image gallery? we can do this for RAD image control but can we do the same for RAD image Gallery?
  4. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 12 Aug 2014 in reply to Rahul Link to this post

    Hi Rahul,

    It is possible to bind RadImageGallery with binary data. Please have a look into the sample code snippet which works fine at my end.

    ASPX:
    <telerik:RadImageGallery ID="RadImageGallery1" runat="server" OnNeedDataSource="RadImageGallery1_NeedDataSource" DataDescriptionField="Description" DataImageField="Picture" DataTitleField="CategoryName" LoopItems="true">
    </telerik:RadImageGallery>

    C#:
    protected void RadImageGallery1_NeedDataSource(object sender, ImageGalleryNeedDataSourceEventArgs e)
    {
        RadImageGallery2.DataSource = GetDataTable();
    }
    public DataTable GetDataTable()
    {
        string query = "SELECT [Picture], [Description], [CategoryName] FROM [Categories]";
     
        String ConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection conn = new SqlConnection(ConnString);
        SqlDataAdapter adapter = new SqlDataAdapter();
        adapter.SelectCommand = new SqlCommand(query, conn);
     
        DataTable dtImageGallery = new DataTable();
     
        conn.Open();
        try
        {
            adapter.Fill(dtImageGallery);
        }
        finally
        {
            conn.Close();
        }
     
        return dtImageGallery;
    }

    Thanks,
    Princy.
  5. Rahul
    Rahul avatar
    14 posts
    Member since:
    Feb 2013

    Posted 12 Aug 2014 in reply to Princy Link to this post

    Thank you for your Help, I have implemented the same in my page and it works fine, but when I am tring to put this control inside RAD grid as a item template it is not working. so is it possible to add RAD image gallery conrol inside RAD Grid
  6. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 12 Aug 2014 in reply to Rahul Link to this post

    Hi Rahul,

    Please have a look into the modified code snippet which works fine at my end.

    ASPX:
    <telerik:RadGrid ID="rgrdOrders" runat="server" DataSourceID="sqldsOrders">
        <MasterTableView>
            <Columns>
                <telerik:GridTemplateColumn>
                    <ItemTemplate>
                        <telerik:RadImageGallery ID="RadImageGallery2" Height="350px" Width="600px" runat="server" OnNeedDataSource="RadImageGallery1_NeedDataSource" DataDescriptionField="Description" DataImageField="Picture" DataTitleField="CategoryName" LoopItems="true" RenderMode="Auto" Skin="Metro">
                            <ToolbarSettings ShowSlideshowButton="true" ShowItemsCounter="true" ItemsCounterFormat="Images {0} of {1}" />
                            <ThumbnailsAreaSettings ThumbnailWidth="120px" ThumbnailHeight="80px" Height="80px" />
                            <ImageAreaSettings Height="300px" />
                            <ClientSettings>
                                <AnimationSettings SlideshowSlideDuration="4000">
                                </AnimationSettings>
                            </ClientSettings>
                        </telerik:RadImageGallery>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    <asp:SqlDataSource ID="sqldsOrders" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT [CategoryName] FROM [Categories]"></asp:SqlDataSource>

    C#:
    protected void RadImageGallery1_NeedDataSource(object sender, ImageGalleryNeedDataSourceEventArgs e)
    {
        RadImageGallery imageGallery = (RadImageGallery)sender;
        imageGallery.DataSource = GetDataTable();
    }

    Thanks,
    Princy.
  7. Louis
    Louis avatar
    3 posts
    Member since:
    Dec 2012

    Posted 04 Dec 2016 in reply to Princy Link to this post

    MAy I also have assistance with this

    I have followed the suggestion solution for Need Data Source and am getting the following error. Also attached my code

     

     

  8. Sreeram
    Sreeram avatar
    4 posts
    Member since:
    Nov 2016

    Posted 04 Dec 2016 Link to this post

    I have a rad grid with columns Album name,Created by.and records three are there.when i expand that album name,that nested view template (image gallery) will appears. that particular album name images from database should be bind to rad image gallery.that images are in binary format.what to do??? please help me guyzzzz...i want it immediately.please please
  9. Sreeram
    Sreeram avatar
    4 posts
    Member since:
    Nov 2016

    Posted 05 Dec 2016 in reply to Princy Link to this post

    What is the datatype of picture in database (SQL)...i have a column with datatype var binary in db,i am giving that column as a data imamge field,but it was not showing my pictures,please help me...and one more thing,with in that rad image gallery i want to put a template called media player.it,s not coming,showing design time error.i'm using 2014 version of telerik.is there any solution for that.please help me guys...please
  10. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2011 posts

    Posted 08 Dec 2016 Link to this post

    Hi Sreeram,

    The DataImageField will specify the field containing the binary data for the image, so if the RadImageGallery is bound correctly, the images should be displayed. Can you please share the configuration related to the RadImageGallery and the code related to the binding of the control, so we can have a better idea of the current implementation?

    Looking forward to your reply.


    Regards,
    Konstantin Dikov
    Telerik by Progress
    Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
  11. Sreeram
    Sreeram avatar
    4 posts
    Member since:
    Nov 2016

    Posted 08 Dec 2016 in reply to Konstantin Dikov Link to this post

    Please See the image .you will understand my problem,,,
  12. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2011 posts

    Posted 12 Dec 2016 Link to this post

    Hi Sreeram,

    RadImageGallery support templates since Q1 2015, so if you need to use that functionality you need to upgrade to a newer version.

    As for the binding problem, first thing that you should have in mind is that you need to set the DataSource only for the RadImageGallery that fires the OnNeedDataSource event. Traversing all data items is unnecessary. You can get reference to the current RadImageGallery through the event arguments: 
    RadImageGallery gallery = sender as RadImageGallery;

    If the images are not displayed correctly I would recommend that you test the RadImageGallery configuration outside RadGrid and use an existing album name for retrieving the data for the test control and see if the images will be displayed.
      
    Looking forward to your reply with the result.


    Best Regards,
    Konstantin Dikov
    Telerik by Progress
    Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
Back to Top