Prasanna Prasanna - 1 year ago 97 Question

How to get table column count programmatically

I am using table where I have to get the number of columns, I wonder there is no any property for table like grid has "Gridview.columns.count".
Please suggest.

Answer Source

I think there is .count property for table class but it support over .net framework 3.0 and above see below snippet

//add table first
Table tbl = new Table();
int columnsToAdd = 4;
for (int x = 0; x < columnsToAdd; x++)
tbl.Columns.Add(new TableColumn());
//then get table count
int columns = tbl.Columns.Count;

hope it helps

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download