Binding Binary Image to RAD Image Gallery

9 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. UI for ASP.NET Ajax is Ready for VS 2017
  4. 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?
  5. 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.
  6. 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
  7. 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.
  8. Louis
    Louis avatar
    3 posts
    Member since:
    Dec 2012

    Posted 3 days and 11 hours ago 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

     

     

  9. Sreeram
    Sreeram avatar
    2 posts
    Member since:
    Nov 2016

    Posted 2 days and 14 hours ago 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
  10. Sreeram
    Sreeram avatar
    2 posts
    Member since:
    Nov 2016

    Posted 2 days and 10 hours ago 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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017