I am using the following query:
string query = @"SELECT r.id, user_name, user_phone, date_create, REPLACE( date_payment, '0000-00-00 00:00:00', 'Не оплачено' ) as
date_payment, payment_method, amount, rs.name_ru
FROM request AS r, request_status AS rs
WHERE r.status = rs.id";
And i am binding datatemplate in the following way:
DataTemplate>
<TextBlock VerticalAlignment="Center" Text="{Binding date_payment}" Width="135" />
</DataTemplate>
Its throwing correct output except the “date_payment” Its output value comes “System.Byte[]“.
please help!!!
Thank from MBen
class ByteArrayToString : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null)
{
var listOfBytes = value as Byte[];
string output = "";
output = System.Text.Encoding.UTF8.GetString(listOfBytes);
return output;
}
return "";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return DependencyProperty.UnsetValue;
}
}
date_paymentis an Array, and you didn’t provide any way for WPF for displaying it, so it callsToString. You can provide a data converter for it.Add a resource to your Window or page :
Use it in your
TextBlockas such :Now you need to add a new class that does the conversion :