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

Hide Show Imagebuttons in RadGrid based on Data

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

Sort by
0
Accepted
Martin
Telerik team
answered on 21 Jul 2009, 12:53 PM
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.
0
Andy Green
Top achievements
Rank 2
answered on 22 Jul 2009, 07:35 AM
Thanks, with some tweaks it works exactly as I want it.

Andy
Tags
Grid
Asked by
Andy Green
Top achievements
Rank 2
Answers by
Martin
Telerik team
Andy Green
Top achievements
Rank 2
Share this question
or