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

[Solved] How can I add an EmptyItemTemplate to a GridTemplateColumn?

2 Answers 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Edwin Burns
Top achievements
Rank 1
Edwin Burns asked on 08 Jul 2009, 01:37 PM
I have the below GridTemplateColumn bound from a sql data source.  I need help developing an empty Item template or I need a way to check to see if there is a value in MSDSLocation. Any thoughts on this would be appreciated.
 
<telerik:GridTemplateColumn HeaderText="MSDS" DataField="MSDSLocation"> 
    <ItemTemplate> 
        <a href='<%# Eval("MSDSLocation") %>' target="_blank"> 
            <img src="/images/icons/msds-icon.gif" alt='<%# Eval("Name") +" MSDS" %>' style="border: none; width: 40px;" />
        </a> 
    </ItemTemplate>
</telerik:GridTemplateColumn>

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 Jul 2009, 05:04 AM
Hi Edwin,

I hope you are trying to set the visibility of the image in the GridTemplateColumn depending on the value of the DataField. If so give a try with the following approach and see whether it helps.

ASPX:
 
 
 <telerik:GridTemplateColumn HeaderText="MSDS" DataField="MSDSLocation"
                  <ItemTemplate> 
                  <href='<%# Eval("MSDSLocation") %>' target="_blank" runat="server"  visible='<%# DataBinder.Eval (Container.DataItem,"MSDSLocation").ToString()!=String.Empty?true:false %>'   >  
                         <img src="/images/icons/msds-icon.gif" alt='<%# Eval("Name") +" MSDS" %>' style="border: none; width: 40px;" /> 
                      </a>  
                </ItemTemplate> 


Thanks
Shinu
0
Edwin Burns
Top achievements
Rank 1
answered on 09 Jul 2009, 06:41 PM
Your approach worked for that situation. Thanks. However, I am still curious if there is any thing like an empty item template for gridtemplatecolumns ?
Tags
Grid
Asked by
Edwin Burns
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Edwin Burns
Top achievements
Rank 1
Share this question
or