How to display image inside my GridView in my .ascx control - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

How to display image inside my GridView in my .ascx control

  • How to display image inside my GridView in my .ascx control
  • Hi everyone,

    I have a problem displaying image inside gridview in ascx control.

    I used <asp:ImageField DataImageUrlField="???" HeaderText="Image"></asp:ImageField> , is this the correct way? and  I don't know the DataImageUrlField   fill with.

    As addition, is <asp:GridView a good way to list my custom content in sitefinity?





    My code:

    .ascx file used in widget:

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="wucSupplier2.ascx.cs" Inherits="SitefinityWebApp.wucSupplier2" %>

    <asp:GridView ID="GridView1" runat="server"  AutoGenerateColumns="False">
            <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
            <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
            <asp:ImageField DataImageUrlField="???" HeaderText="Image"></asp:ImageField>



    .cs file

    using System;
    using System.Linq;
    using System.Collections.Generic;
    using Telerik.Sitefinity.Model;
    using Telerik.Sitefinity.DynamicModules;
    using Telerik.Sitefinity.Data.Linq.Dynamic;
    using Telerik.Sitefinity.DynamicModules.Model;
    using Telerik.Sitefinity.Utilities.TypeConverters;
    using Telerik.Sitefinity.GenericContent.Model;

    namespace SitefinityWebApp

        public partial class wucSupplier2 : System.Web.UI.UserControl
            protected void Page_Load(object sender, EventArgs e)
                // Fetch a collection of "live" and "visible" supplier items.
                var myCollection = GetDataItems();

                // Binds the collection of Person items to the RadGrid
                GridView1.DataSource = myCollection;

            // Gets a collection of "live" and "visible" supplier items.
            public IQueryable<DynamicContent> GetDataItems()
                DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager();
                Type supplierType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.SBC.Supplier");

                // Fetch a collection of "live" and "visible" supplier items.
                var myCollection = dynamicModuleManager.GetDataItems(supplierType)
                    .Where(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live && i.Visible == true);

                return myCollection;

  • Hello everyone,

    I checked in the table that the dynamic module created, seems there is no field indicating the image data is kept,  do i need something like join table to get the image data to be binded in my gridview?

    Does anyone can help me?