Determining Column Number from Column Name

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

In .net2 using VB (Visual Web), I have the following code that properly
determines the column name from the column number (5 in this example) from a
single row table.

ColName = tempA.Table.Columns(5).ColumnName()

I can't figure out the code to return the column number if I have the column
name.

E.g., something like this:

ColNumber = tempA.Table.ColumnName(Y1).ColumnNumber()

Can someone point me in the right direction?

Thanks

Jeff
 
Loop through the columns and do a If ....Then and if it equals the column
name you are looking for then you have your column number.
 
vbnetdev said:
Loop through the columns and do a If ....Then and if it equals the column
name you are looking for then you have your column number.


Thanks
After messing with this for a long while, I got the following to work.

CurColNumber = tempA.Table.Columns.IndexOf(ColName)
 
In .net2 using VB (Visual Web), I have the following code that properly
determines the column name from the column number (5 in this example) from a
single row table.

ColName = tempA.Table.Columns(5).ColumnName()

I can't figure out the code to return the column number if I have the column
name.

E.g., something like this:

ColNumber = tempA.Table.ColumnName(Y1).ColumnNumber()

Can someone point me in the right direction?

Thanks

Jeff

DataColumns have an Ordinal property. Could this be what you are looking
for?
 
Back
Top