Prasanna Prasanna - 10 days ago 5
Vb.net Question

How to get asp.net table column count programmatically

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

Answer

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