Way to look up index for Cell in datagrid

P

Paul

Is there a way to look up the index for cells in a data grid. I do not
like hard coding numbers into my programs (other than 0 or 1)

Sub DisplayBoundColumnValues(sender as Object, e as
DataGridCommandEventArgs)
Dim bc1 as String = e.Item.Cells(1).Text
Dim bc2 as String = e.Item.Cells(2).Text

End Sub

Thank You
 
E

Eliyahu Goldin

Are you looking for a way of accessing cells by column name? Write a simple
method that will loop through the grid's Columns collection, match column
names, and return the index of the matched one. This won't work if the
columns are autogenerated.

Eliyahu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top