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

[Solved] Column count of radgrid always 1 when binding a dataset.

2 Answers 146 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bex
Top achievements
Rank 1
Bex asked on 28 Jan 2010, 05:09 PM
Hello!

I have a radgrid and when I bind a dataset with 3 columns to it, when I submit the page and check the column count of the grid, it always come back as 1.

In the Grid_needdatasource I have the following code:

   DataSet accounts = ExternalAccounts.getAllExternalAccounts(ExternalAccount.ConnectionString, query);
   autoGeneratedGrid.DataSource = accounts;

and then when I submit the page I want to count the number of columns in the grid by doing this:
grid.Columns.Count

It always comes back as 1 even though I can see 3 columns! I am auto generating the columns.
What's going on?

Bex


2 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 29 Jan 2010, 01:06 PM
Hello Becky,

The Columns collection of the grid contains only the statically declared columns. Try using the following property for your purposes (please, keep in mind that special columns such as EditCommand, Expand/Collapse etc. are also included):

RadGrid1.MasterTableView.RenderColumns.Length

I hope this helps.

All the best,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Bex
Top achievements
Rank 1
answered on 29 Jan 2010, 01:42 PM
Thanks that really helps!
Tags
Grid
Asked by
Bex
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Bex
Top achievements
Rank 1
Share this question
or