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

Image in DataTable databound to a GridView

3 Answers 89 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jose Simas
Top achievements
Rank 2
Jose Simas asked on 07 Jun 2010, 04:16 PM
Hi,

I have a grid that is bound to a DataTable. The structure of the DataTable varies at runtime so I cannot set the columns at design time (AutoGenerateColumns is set to true). When a column of the DataTable is of type System.Byte[] the grid shows "System.Byte[]" and I would like it to show an image instead. I am guessing I should be using a DataTemplate for this type but I am unsure of how to do this with the GridView, can you please help or point me to the relevant resource?

Cheers,
Jose

3 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 07 Jun 2010, 04:27 PM
Hi Jose Simas,

 Please check out this blog post.

All the best,
Yavor Georgiev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jose Simas
Top achievements
Rank 2
answered on 07 Jun 2010, 04:42 PM
Hi Yavor,

Thank you for the link. I will definitely use the converter in that blog post but my scenario is slightly different because I have AutoGenerateColumns=true whereas the example in the blog post has AutoGenerateColumns=false.

My question is: Does the GridView, when bound to a DataTable, allows replacing the CellTemplate for a column depending on the type stored in the column of the DataTable?

Cheers,
Jose



0
Yavor Georgiev
Telerik team
answered on 07 Jun 2010, 04:52 PM
Hello Jose Simas,

 To achieve more control over the column generation, you need to handle the AutoGeneratingColumn event and assign the DataTemplate where necessary.

Best wishes,
Yavor Georgiev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Jose Simas
Top achievements
Rank 2
Answers by
Yavor Georgiev
Telerik team
Jose Simas
Top achievements
Rank 2
Share this question
or