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

count of radgrid bound columns

1 Answer 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Erin
Top achievements
Rank 1
Erin asked on 18 Oct 2013, 12:10 PM
Hi,
I want to get the count of radgrid bound columns? How to get this?

Thanks,
Erin

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Oct 2013, 12:13 PM
Hi Erin,

Please try the following code to get the count of the columns in radgrid.

C#:
int colCount = RadGrid1.Columns.Count;

If you want to get the count of only GridBoundColumn,please try the following code.

C#:
int count = 0;
protected void RadGrid1_PreRender(object sender, EventArgs e)
 {
    foreach (GridColumn col in RadGrid1.MasterTableView.RenderColumns)
    {
        if (col.ColumnType == "GridBoundColumn")//Checking for BoundColumn
        {
             count = count + 1; //Get the count here
        }
    }
 }

Thanks,
Princy
Tags
Grid
Asked by
Erin
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or