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()
{
string qry = "Select ID, CustName, Cust_DOB, Contact_No, Cust_Photo From custInfo";
try
{ MainWindow.myCon.Open(); }
catch { };
OleDbDataAdapter da = new OleDbDataAdapter(qry, MainWindow.myCon);
DataTable dt = new DataTable();
da.Fill(dt);
try
{ 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" >
<DataGrid.Columns>
<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">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding ImageFilePath}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
Please help...!!!