RadImageTile Source

2 posts, 0 answers
  1. Alexis
    Alexis avatar
    4 posts
    Member since:
    Jul 2017

    Posted 21 Jul 2017 Link to this post

    Hey,

    My problem is that I'm trying to create a RadTileList programmatically to populate an Intranet staff page.

    We've developed a page in which users can choose an image of themselves, along with fill out the details we don't keep in Active Directory, and then we pull the photo, AD information and profile information and pop it into a staff page. Works beautifully, and the Telerik controls really improve the look and feel of it.

    Then we wanted to make a series of image galleries for different teams, different job roles etc. We can pull the data for these groups no problem. Then the plan is that everyone gets their image put into a gallery, which we're going to use the RadToolTip functionality on to preview before they can open the page to learn all about the member of staff. Herein lies my problem, because I can't populate the RadTileList using the byte array (byte[]) images.

    Below is an example of how I'm TRYING to code it. Unfortunately I have so much to do on this project and so little time to do it in that I really can't afford to be spending much longer trying to get this to work. Any chance you could provide a solution?

    protected void LoadStaffList(DataTable staffList, Image notAvailable)
    {
        var tileList = new RadTileList();
        var tileGroup = new TileGroup();
        var memoryStream = new MemoryStream();
        var image = Resources.photonotavailable;
        image.Save(memoryStream, ImageFormat.Png);
     
        foreach (DataRow row in staffList.Rows)
        {
            var imageTile = new RadImageTile();
            var userPhoto = row["UserPhoto"] != DBNull.Value ? row["UserPhoto"] : null;
            imageTile.DataItem = (byte[]) userPhoto ?? memoryStream.ToArray(); <-- YOU CAN'T DO THIS!!
            imageTile.Shape = TileShape.Square;
            tileGroup.Tiles.Add(imageTile);
        }
     
        tileList.Groups.Add(tileGroup);
        divTeamInformation.Controls.Add(tileList);
    }

    I'm assuming there's a way to use a RadBinaryImage or something else in place of the RadImageTile? Or some other way to set the data without writing the byte array to a temp file and then setting the temp file as the Image Source, because both of those would be incredibly annoying to have to do.

    Any help you could provide would be massively appreciated. Apologies if it's a duplicate topic but I couldn't see one like it.

    Thanks,

    -Alexis

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4080 posts

    Posted 26 Jul 2017 Link to this post

    Hi Alexis,

    The following KB shows two approaches you can try: http://www.telerik.com/support/kb/aspnet-ajax/tilelist/details/images-stored-in-a-database-in-radtilelist. The first relies on quering the database via a custom handler, the second uses the data directly via a RadBinaryImage. I can suggest trying out each of them with one simple image to see which one you prefer and then incorporate it in the tilelist.

    Regards,

    Marin Bratanov
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top