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

show image in grid column if datafield is true

2 Answers 267 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mario
Top achievements
Rank 2
Mario asked on 02 Jul 2009, 01:02 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 03 Jul 2009, 04:56 AM
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
0
Mario
Top achievements
Rank 2
answered on 09 Jul 2009, 08:55 AM
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
Tags
Grid
Asked by
Mario
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Mario
Top achievements
Rank 2
Share this question
or