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

How To Hide GridTemplateColumn In RadGrid

1 Answer 327 Views
Grid
This is a migrated thread and some comments may be shown as answers.
johnson lim
Top achievements
Rank 1
johnson lim asked on 04 Apr 2010, 11:55 AM
Hi, i need to hide some buton in RadGrid according to user access right.
All the column in my radgrid are pair with ItemTemplate and EditItemTemplate.
The button in side the RadGrid i need to hide is in  ItemTemplate.

I have try to hide it in ColumnCreated with ColumnUniqueName but fail.

I try to hide it in ItemDataBound but the column is neither in edit, Add mode.And  it is also not a Header,Pager, Footer Item.

Does anyone has idea on this ?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Apr 2010, 05:39 AM
Hi,

You can access the controls inside ItemTemplate in ItemDatBound event by using the GridDataItem object.

C#:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) 
    if (e.Item is GridDataItem) 
    { 
      if (((GridDataItem)e.Item)["CustomerID"].Text == "ALFKI"
        ((GridDataItem)e.Item).FindControl("btn1").Visible = false
      else 
        ((GridDataItem)e.Item).FindControl("btn1").Visible = true
    } 

Regards
Princy
Tags
Grid
Asked by
johnson lim
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or