How display images from sql datbase using radList view

2 posts, 0 answers
  1. Anoop
    Anoop avatar
    18 posts
    Member since:
    Dec 2012

    Posted 21 Jan 2013 Link to this post

    I am using c# and sql database.
    Database contains two filed 1.ID - Int
                                                 2.Picture - Image
    I had binded the database to radList view ,picture is set as Display member and ID is set as value member.
    Problem is pictures are not showing .How to display pictures ?
  2. Stefan
    Stefan avatar
    2891 posts

    Posted 24 Jan 2013 Link to this post

    Hi Anoop,

    Thank you for writing.

    To assign an image to ListViewData item from your underlying DataRow, you should use the ItemDataBound event as explained in this help article. Here is a small sample:
    public Form1()
        DataTable t = new DataTable();
        t.Columns.Add("Image", typeof(Image));
        t.Rows.Add("1", Image.FromFile(@"C:\Program Files (x86)\Telerik\RadControls for WinForms Q3 2012\Examples\QuickStart\Resources\BE.png"));
        t.Rows.Add("1", Image.FromFile(@"C:\Program Files (x86)\Telerik\RadControls for WinForms Q3 2012\Examples\QuickStart\Resources\BR.png"));
        t.Rows.Add("1", Image.FromFile(@"C:\Program Files (x86)\Telerik\RadControls for WinForms Q3 2012\Examples\QuickStart\Resources\BUL.png"));
        radListView1.ItemDataBound += radListView1_ItemDataBound;
        radListView1.DataSource = t;
        radListView1.DisplayMember = "ID";
    void radListView1_ItemDataBound(object sender, Telerik.WinControls.UI.ListViewItemEventArgs e)
        DataRowView rowView = e.Item.DataBoundItem as DataRowView;
        e.Item.Image = rowView.Row["Image"] as Image;

    I hope this helps.

    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top