Click here to Skip to main content
15,615,469 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Team,

I am developing one application where in I have requirement to display Customer photo to the datagrid in WPF C# From Access Database (Image stored in OLE Object format- binary).

There are couple of examples on google but not able to find relevant.

I am showing customer info on grid like ...Cust_name, DOB, Contact_No, Cust_Photo.

I have below code -

private void Button_Click(object sender, RoutedEventArgs e)
           grd.ItemsSource = Get_Grd_Data().DefaultView;

 private DataTable Get_Grd_Data()
            // Grd.ItemsSource = null;
            string qry = "Select ID,  CustName, Cust_DOB, Contact_No, Cust_Photo From custInfo";
            { MainWindow.myCon.Open(); }
            catch { };

            OleDbDataAdapter da = new OleDbDataAdapter(qry, MainWindow.myCon);
            DataTable dt = new DataTable();

            { MainWindow.myCon.Close(); }
            catch { };
            return dt;

<DataGrid x:Name="grd" HorizontalAlignment="Left" Margin="10,62,0,0" VerticalAlignment="Top" Height="422" Width="740" BorderThickness="0,1,1,1" ClipboardCopyMode="IncludeHeader" ClipToBounds="True" AlternatingRowBackground="#FFC7E4F7" Background="#FFCADDF7" AutoGenerateColumns="False" >
                <DataGridTextColumn   Binding="{Binding ID}"  ClipboardContentBinding="{x:Null}" Header="ID" />
                <DataGridTextColumn Binding="{Binding CustName}" ClipboardContentBinding="{x:Null}" Header="Customer Name"/>
                <DataGridTextColumn Binding="{Binding Cust_DOB}" ClipboardContentBinding="{x:Null}" Header="Date of Birth"/>
                <DataGridTextColumn Binding="{Binding Contact_No}" ClipboardContentBinding="{x:Null}" Header="Contact Number"/>
                <DataGridTemplateColumn Header="Customer Photo">
                            <Image Source="{Binding ImageFilePath}" />

Please help...!!!
Updated 11-Aug-15 2:25am
Herman<T>.Instance 11-Aug-15 7:21am    
- does the query return an image?
- does the gridview ha a picture or image component?

This is TOO less information
Pravinkarne.31 11-Aug-15 7:31am    
Query getting output as -

ID CustName Cust_DOB Contact_No Cust_Photo
1 Client Name 1 11-08-1983 1234567890 System.Byte[]

I am trying to add "DataGridTemplateColumn" but not to display- Convert-bind binary data to this column...

Your help and guidance will be very appreciated..!!!

Thank you!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900