This is a migrated thread and some comments may be shown as answers.

Display Image in RadGridView using ItemsSource Bound to LinqToSQL via WCF

6 Answers 101 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Christian Casutt
Top achievements
Rank 1
Christian Casutt asked on 30 Jan 2010, 08:41 PM
What i have:

A SQL table with a column DocTypeIcon of data type Image.
I'm using LinqToSql to retrieve the data. Using WCF i ship the data to a Silverlight Application. In the Silverlight Application i have a Class (kind of mediator) to do the annotation for the fields (ColumnHeaders) like:

[DisplayAttribute(AutoGenerateField = false)]
public String DocId { get; set; }
[DisplayAttribute(Name="Document Name")]
public String DocName { get; set; }



etc..

The Items retrieved from the database are then added to a List<DatabaseRecords>. The list is then bound to a RadGridView.ItemsSource. All the data is displayed almost perfectly, but i don't get it to display the image...

i tried this:

                        <telerikGridView:RadGridView x:Name="dgDocuments" HorizontalAlignment="Left" Margin="16,189,0,278">
                            <telerikGridView:RadGridView.Columns>
                                <telerikGridView:GridViewImageColumn Header="DocTypeIcon" DataMemberBinding="{Binding DocTypeIcon}"/>
                            </telerikGridView:RadGridView.Columns>
                        </telerikGridView:RadGridView>

help's/comments are really appreciated!

Christian




6 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 01 Feb 2010, 07:12 AM
Hi Christian,

Can you post more info about the image type saved in this field?

Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Christian Casutt
Top achievements
Rank 1
answered on 01 Feb 2010, 07:31 AM
Hi Vlad

It's a PNG. And it comes in as

?dr.DocTypeIcon.GetType();
{SomeSilverlightApp.DatabaseServiceSubscription.Binary}

cheers, Christian


0
Pavel Pavlov
Telerik team
answered on 01 Feb 2010, 09:35 AM
Hi Christian Muggli,

Have you checked this online example  ? I believe it is simillar to your scenario.

All the best,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Christian Casutt
Top achievements
Rank 1
answered on 01 Feb 2010, 09:49 AM
Hi Pavel

Yes, my code is based on that example. But i hade to put some kind of 'mediator-class' between the the RadGridView.ItemsSource and the results that i get from the WCF (i do NOT use RIA) to manage the ColumnHeader and AutoGeneration of the Columns using DataAnnotations (i wrote the in my initial post, but maybe that didn't came too clear..).
The image gets displayed correctly in the Grid as long as i don't have my mediator-class between the .ItemsSource and the results i get from the WCF.
So the question is:
The result i get from WCF is of type:
{SomeSilverlightApp.DatabaseServiceSubscription.Binary} 





When i declare the type in my Class like (is that the correct data type??):

public Byte[] img { getset; } 

in the XAML File i declared it like:

<telerikGridView:GridViewImageColumn Header="img" DataMemberBinding="{Binding img.Bytes}"/>

and i tried also the DataMemberBinding="{Binding img}"

i always get an empty cell...

cheers,

Christian
0
Pavel Pavlov
Telerik team
answered on 04 Feb 2010, 09:01 AM
Hello Christian Muggli,


Everything seems ok in your code. You can feed the ImageColumn with bytes array and it should work OK .  Without having the code of your project I may only guess what causes the trouble but here are some thoughts : 

The  problem may be in the asynchronous nature of the service - the data may come a bit later when the column is already initialized .  This can be easily checked - for your mediator class please inherit and implement the INotifyPropertyChanged interface. This way  RadGridView will sense any on-the-fly changes and will update the ui (e.g. if data comes a  bit later ) .

If this does not solve the problem I may be in help the following ways :

1. You can open a support ticket and send me you project so I can try fix it for you. ( any content/code  will be treated as confidential).

2. If 1. is not applicable , you may just paste me as much relevant code as possible here so I can try to resemble the problem here.

Greetings,
Pavel Pavlov
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Christian Casutt
Top achievements
Rank 1
answered on 09 Feb 2010, 09:31 AM
Hi Pavel

Thanks for your suggestions.

in the meanwhile, i changed my application to take the graphics out of a resource file embedded in the Silverlight Application. That's because i had and still have time-pressure releasing the product.

Still, if i ever find time to do a sample / test solution just to know whether it would work or not i would post it here for the community.

thanks for your time

Christian
Tags
GridView
Asked by
Christian Casutt
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Christian Casutt
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Share this question
or