show image in grid column if datafield is true

3 posts, 1 answers
  1. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 02 Jul 2009 Link to this post

    hi,

    i searched through demos, forum and codesection, but i don't know how to implement to show an image in a grid column if the datafield is true and keep it invisible if its false. (Or 0 for false and 1 for true..)

    thanks mario
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Jul 2009 Link to this post

    Hello,

    Try adding GridTemplateColumn with image and set the Visibility property as shown below in order to display image based on the cell value.

    ASPX:
     
    <telerik:GridTemplateColumn UniqueName="TempColumn"
        <ItemTemplate> 
            <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/AddRecord.gif" Visible='<%# (DataBinder.Eval(Container.DataItem,"MartalStatus").ToString() == "1" ) ? false : true %>' /> 
        </ItemTemplate> 
    </telerik:GridTemplateColumn> 

    -Shinu
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 09 Jul 2009 Link to this post

    good idea,

    i tried:

    DataBinder.Eval(Container.DataItem,"Metainformation.is_checkedout")

    cause i thought -> Container.DataItem: is the current row object.
                                 Metainformation.is_checkedout: its a Linq obect that got a relationto the Metainformation table with the column is_checkedout. When i use GridDataBoundColumn its working this way to adress a propertie in a lower child level of the row object

    but im not using AutoGenerated Columns. So i think it didnt work as i tried this approach.




    I have a grid for documents. which got a relation to the Metainformation table wich got the column bool is_checkedout. which value i need to retrieve for knowing if the image should be visible or not.

    i tryd to attach a OnImageLoad method to the OnLoad event of the asp:Image control. but then im not able to retrieve the bool value, cauese the Image control doenst know it..

    what may i do here?

    thx mario
Back to Top