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

Grouping fieldnames

3 Answers 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 10 Jun 2010, 02:02 PM
hi,

  i have a populated grid on a web page. and a server side button. clicking on this button, i want to find out what columns have been used in the grouping.

  i've tried this :

        protected void Button1_Click(object sender, EventArgs e)  
        {              
            foreach (GroupItemCell oCell in grdPendingOrders.GroupPanel.GroupPanelItems)  
            {  
                foreach (Control ctrl in oCell.Controls)  
                {  
                    if (ctrl is System.Web.UI.WebControls.ImageButton)  
                    {  
                        System.Web.UI.WebControls.ImageButton button = ctrl as System.Web.UI.WebControls.ImageButton;  
 
                    }  
                }  
            }  
        }  
 

i thought perhaps from the button i could get the fieldname. (the fieldname is all i want)

but all controls are literals, no imagebuttons. but the grid is populated with data - i thought it might be a post back issue.

can you please help

thanks

andy



  


 

3 Answers, 1 is accepted

Sort by
0
Andy
Top achievements
Rank 1
answered on 10 Jun 2010, 04:23 PM
i should also point out that the grouppanel.grouppanelitems object always matches the number of fields i have selected in the group by expression. BUT, when i drill down, i can't see any reference to the name of the fields. I thought text might have been it, but it's always blank.
0
Shinu
Top achievements
Rank 2
answered on 11 Jun 2010, 08:46 AM
Hello Andy,

You can try the following code snippet to get the fieldname of the columns that have been used for grouping.

C#:
 
 protected void Button1_Click(object sender, EventArgs e) 
    { 
        foreach (GridGroupByExpression expression in RadGrid1.MasterTableView.GroupByExpressions) 
        { 
            string fieldname = expression.GroupByFields[0].FieldName;  
        } 
    } 

Regards,
Shinu.
0
Andy
Top achievements
Rank 1
answered on 11 Jun 2010, 09:49 AM
Hello Shinu,

  not enough positive adjectives to throw at you. really appreciate your help.

  thank you very, very much ! 
 
regards,
Andy
Tags
Grid
Asked by
Andy
Top achievements
Rank 1
Answers by
Andy
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or