Hiding Image In GridTemplateColumn on Null Data

4 posts, 0 answers
  1. Jeff Wickersham
    Jeff Wickersham avatar
    24 posts
    Member since:
    Mar 2009

    Posted 01 Jul 2009 Link to this post

    Pointers needed with the following
    I need to hide the image / functionality below if the data value is null

    <telerik:GridTemplateColumn ItemStyle-Width="22px" UniqueName="CertFileName">
              <ItemTemplate>
                <asp:ImageButton ID="CertFileName" Runat="server" AlternateText="Download Certificate" ToolTip="Download Certificate"
                ImageUrl="../Images/Cert.gif" CommandArgument='<%# DataBinder.Eval(Container,"DataItem.CertFileName")%>' CommandName="CertFileName"/>
              </ItemTemplate>
           </telerik:GridTemplateColumn> 

    Thanks

  2. Terry Webster
    Terry Webster avatar
    48 posts
    Member since:
    Aug 2003

    Posted 01 Jul 2009 Link to this post

    You can add a visible property tag to the asp imagebutton:

    VB.NET Example:

        

    Visible='<%# if(TypeOf Eval("CertFileName") is System.DBNull, False, True) %>' 

     

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 01 Jul 2009 Link to this post

    HI Jeff,

    You may set the Visible property of the ImageButton as shown below.

    ASPX:
     
      
     
    <asp:ImageButton ID="CertFileName" Runat="server" Visible='<%# DataBinder.Eval (Container.DataItem,"CertFileName").ToString()!=String.Empty?true:false %>'  AlternateText="Download Certificate" ToolTip="Download Certificate" 
                ImageUrl="../Images/Cert.gif" CommandArgument='<%# DataBinder.Eval(Container,"DataItem.CertFileName")%>' CommandName="CertFileName"/> 

      or

     
    <asp:ImageButton ID="CertFileName" Runat="server" Visible='<%# DataBinder.Eval (Container.DataItem,"CertFileName")!=null?true:false %>'  AlternateText="Download Certificate" ToolTip="Download Certificate" 
                ImageUrl="../Images/Cert.gif" CommandArgument='<%# DataBinder.Eval(Container,"DataItem.CertFileName")%>' CommandName="CertFileName"/> 


    Thanks
    Shinu
  5. Jeff Wickersham
    Jeff Wickersham avatar
    24 posts
    Member since:
    Mar 2009

    Posted 06 Jul 2009 Link to this post

    Awesome, thanks for the assistance
Back to Top