The WebDataGrid columns are auto generated in code. I want to count the columns
int
columnCnt = HunterDistributorWebDataGrid.Columns.Count;
after WebDataGrid.DataBind(); It returned zero. The columns count works for bound column. I also tried to hide a column but it didn't work.
HunterDistributorWebDataGrid.Columns[0].Hidden =
true;
How do I count the auto generated columns? Thanks.
Hi uli,
This behavior was copied from the Microsoft GridView. The columns can be generated, but since you did not create them, they are not in the Columns collection.
regards,
David Young
This is a step back compared to the UltraWebGrid.
Hi All,
The Columns collection contains only columns that you have added to the collection. It does not contain any autogenerated columns. You can scan your datasource and create the columns that you need. And then turn off AutogenerateColumns.
regards,David Young
I used the code suggested in the Page Pre-Render (this is one of the methods that happens after the Grid's IntiliazeRow event and it worked well. Just annoying that you have to have a work around.
The only other issues is if the grid has no rows, then you cannot really access these to show/hide because you need a Rows object which is nothing.
Infragistics people is there a better (best practice) way to get to these objects on the server side?
Thanks for the reply. So are you saying that on InitializeRow or some event after DataBinding, I can use the rows(0).Items(X).Columns object to edit the columns?