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

Number of columns in radgrid

2 Answers 550 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adolfo
Top achievements
Rank 1
Adolfo asked on 22 Nov 2010, 05:32 PM
hello everybody

I have a question,
¿How can i get the number of columns in a radgrid when the property autogeneratecolumns is true?

when i add the columns programatically,  i use the next code
-----------------------------------------------
int cCount;
cCount = RadGrid1.Columns.Count;
-----------------------------------------------
and perfect,  cCount set the number of columms,  but, when i add columns automatically and the option autogeneratecolumns is in true, cCount only show zero,

thanks for the collaborationand sorry for my bad English

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 23 Nov 2010, 06:35 AM
Hello Adolfo,

Use the following code to get the column count when using AutoGeneratedColumns.
           int count = RadGrid1.MasterTableView.RenderColumns.Length;

But keep in mind that it includes special columns such as Expand/Collapse, RowIndicatorColumn etc. So for actual column count you can use the following code.
      int count = RadGrid1.MasterTableView.RenderColumns.Length - 2;


Hope this helps.


Regards,
Shinu.
0
Adolfo
Top achievements
Rank 1
answered on 23 Nov 2010, 02:59 PM
thank shinu ,  just that i needed
Tags
Grid
Asked by
Adolfo
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Adolfo
Top achievements
Rank 1
Share this question
or