Hide Show Imagebuttons in RadGrid based on Data

3 posts, 1 answers
  1. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 20 Jul 2009 Link to this post

    Hi

    I have a RadGrid with 5 function buttons. I want to hide / show these images on a row by row basis.

    This is my Rad grid:

     

    <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="EditJobplan" Text="Edit JobPlan" ImageUrl="../App_Themes/Default/Images/JobPlanEdit_24.gif" UniqueName="Change"><HeaderStyle Width="1px" /><ItemStyle Width="1px" /></telerik:GridButtonColumn>

     

     

    <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="EditSession" Text="Edit Sessions" ImageUrl="../App_Themes/Default/Images/SessionEdit_24.gif" UniqueName="View"><HeaderStyle Width="1px" /><ItemStyle Width="1px" /></telerik:GridButtonColumn>

     

     

    <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Assign" Text="Assign" ImageUrl="../App_Themes/Default/Images/JobPlanAssign_24.gif" UniqueName="Assign"><HeaderStyle Width="1px" /><ItemStyle Width="1px" /></telerik:GridButtonColumn>

     

     

    <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Forum" Text="Forum" ImageUrl="../App_Themes/Default/Images/Chat_24.gif" UniqueName="Forum"><HeaderStyle Width="1px" /><ItemStyle Width="1px" /></telerik:GridButtonColumn>

     

     

    <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Preview" Text="Preview" ImageUrl="../App_Themes/Default/Images/Preview_24.gif" UniqueName="Preview"><HeaderStyle Width="1px" /><ItemStyle Width="1px" /></telerik:GridButtonColumn>

     

     


        Protected Sub rgJobPlans_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgJobPlans.ItemDataBound  
            If TypeOf e.Item Is GridDataItem Then  
                Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)  
                Dim data As System.Data.DataRowView = TryCast(e.Item.DataItem, System.Data.DataRowView)  
                If data("Status").ToString() = "1" Then  
                    dataItem("Change").Controls(0).Visible = True 
                Else  
                    dataItem("Change").Controls(0).Visible = False 
                End If  
            End If  
        End Sub 

    The code shows my ItemDataBound event, What is happening is that the entire column is being hidded / shown not the individual rows, what am I doing wrong?

    Andy
  2. Answer
    Martin
    Admin
    Martin avatar
    811 posts

    Posted 21 Jul 2009 Link to this post

    Hi Andy,

    I would offer you to review the attached sample project and let us know if it works for your scenario.

    Best wishes,
    Martin
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 22 Jul 2009 Link to this post

    Thanks, with some tweaks it works exactly as I want it.

    Andy
Back to Top