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

How to interact with controls in HeaderTemplate of DetailGrid ?

2 Answers 50 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phuc
Top achievements
Rank 1
Phuc asked on 16 Aug 2011, 11:51 AM
Hi all,

I have a Grid (master grid) which contains a Detail Grid for each row. In Detail Grid, I have created GridTemplateColumn with HeaderTemplate and ItemTemplate.
HeaderTemplate contains some image buttons which allow user interacting with them. 

In NeedDataSource event of DetailGrid, I have fetched data from DB to bind its data. Depending on a property of each item (row), these image buttons are [displayed and set some properties] or not.

How can I access these image buttons for setting (invisible/visible, CommandArgument -  from DataItem) for them ?

Thanks a lot for your help,
Phuc PHAM

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 16 Aug 2011, 12:01 PM
Hello Phuc,

Try the following code snippet to access controls in HeaderTemplate.

C#:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridHeaderItem && e.Item.OwnerTableView.Name == "DetailTable1")
   {
    GridHeaderItem hItem = (GridHeaderItem)e.Item;
    ImageButton img = (ImageButton)hItem.FindControl("ImageButton1");
    img.Visible = false;
   }
}

Thanks,
Princy.
0
Phuc
Top achievements
Rank 1
answered on 17 Aug 2011, 03:47 AM
Thank you, Princy.
Tags
Grid
Asked by
Phuc
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Phuc
Top achievements
Rank 1
Share this question
or