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

Find GridGroupHeaderItem in EventArgs e?

2 Answers 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 11 May 2010, 08:12 PM
How do I find the GridGroupHeaderItem in EventArgs e

protected void ButtonApprove_Click(object obj, EventArgs e)  
{           
 // loop through rows  
    foreach (GridDataItem item in RadGrid1.MasterTableView.Items)  
    {  
     // How do I access the GridGroupHeaderItem ?  
    }  

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 May 2010, 06:16 AM

Hello Mike,

I guess you have added button in the GridGroupHeader and want to access the groupheader in the Button_Click event. If so, try the  following code snippet in order to achieve the same.

C#:

 
    void btn_Click(object sender, EventArgs e)  
    {  
        Button btn = (Button)sender;  
        GridGroupHeaderItem headerItem = (GridGroupHeaderItem)btn.NamingContainer;           
    } 

If you want to iterate through all the groupheader items, then you can use the following code.

C#:

 
    protected void Button1_Click(object sender, EventArgs e)  
    {  
        foreach (GridGroupHeaderItem headerItem in RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader))  
        {  
              // headerItem is GridGroupHeaderItem  
        }  
    } 

-Shinu.

0
Mike
Top achievements
Rank 1
answered on 12 May 2010, 01:03 PM
Once in the headerItem, how would I access the Header text?

string

 

headerName = Convert.ToString(headerItem["NAME"].Text);

does not seem to work.

 

Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mike
Top achievements
Rank 1
Share this question
or