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

GridViewImageColumn as a URL from DataTable

6 Answers 213 Views
GridView
This is a migrated thread and some comments may be shown as answers.
jwhitley
Top achievements
Rank 1
jwhitley asked on 15 Jun 2010, 05:27 PM
I have a GridViewImageColumn databound to a string column in a datatable which contains a fully qualified http URL. I was hoping this would download and display the image in the grid, but it leaves the cell blank.

Should this work? If not, what is the simplest way to programmatically bind an image, via a URL, to a column?

Thanks.

6 Answers, 1 is accepted

Sort by
0
Accepted
Ваня
Top achievements
Rank 1
answered on 15 Jun 2010, 11:06 PM
You should read this may be it is not exactly the same issue,but I hope it would be helpful for you...


From the following thread you can download an attached sample developed by Vlad (The Telerik team) 
that demonstrates  image column bound to DataTable:

0
Ваня
Top achievements
Rank 1
answered on 15 Jun 2010, 11:50 PM
When i started to investigate these controls (and WPF in general) I always forget to set the DataMemberBinding for the particular imagecolumn
to point to the field name and at a later time I realized that the image will be shown automatically in the grid.......

0
jwhitley
Top achievements
Rank 1
answered on 16 Jun 2010, 09:33 AM
Thanks Vanya, that did indeed help.

I changed my binding from {Binding image} to {Bind [image]} and it magically worked. I'm not sure what the relevance of the square brackets are, but all is good.

Now I have a secondary issue though... the grid does not get updated until all images are downloaded, which is not ideal.
0
Ваня
Top achievements
Rank 1
answered on 16 Jun 2010, 01:32 PM
I know that retrieving and displaying images in a GridView is a little or more a time-consuming task-you can  load the images asynchronously....
As concerned to square brackets if you take a look at MSDN you can see that they 
"they are indicators that more than one name/value pair is possible"-I am not quite sure but indexed properties in databinding are frequently used.....

 In our case {Binding [image]} the image si specified in the binding path to the column 

0
jwhitley
Top achievements
Rank 1
answered on 16 Jun 2010, 02:24 PM
Thanks again. Loading the images asynchronously is what i need to work on, but I will need to change how this is done, as currently the image binding is done from the xaml file and I doubt there is any way to do this via a standard image column without it being synchronous.

My ideas are:

1.) Use a webbrowser control in the grid column rather than an image. I would expect the web browser to work asych, although until i've done the work I'm not sure

2.) Add the images to the grid in code-behind via separate threads.

I think option 2 would be the best, unless someone can tell me otherwise?

Thanks.
0
jwhitley
Top achievements
Rank 1
answered on 16 Jun 2010, 04:59 PM
Have posted the asynch question in a different thread as it's essentially a different problem.

Thanks.
Tags
GridView
Asked by
jwhitley
Top achievements
Rank 1
Answers by
Ваня
Top achievements
Rank 1
jwhitley
Top achievements
Rank 1
Share this question
or