Image in DataTable databound to a GridView

4 posts, 0 answers
  1. Jose Simas
    Jose Simas avatar
    35 posts
    Member since:
    Mar 2009

    Posted 07 Jun 2010 Link to this post

    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
  2. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 07 Jun 2010 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jose Simas
    Jose Simas avatar
    35 posts
    Member since:
    Mar 2009

    Posted 07 Jun 2010 Link to this post

    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



  5. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 07 Jun 2010 Link to this post

    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.
Back to Top